Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104495
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Joaquin Alzola <Joaquin.Alzola@lebara.com> |
| Newsgroups | comp.lang.python |
| Subject | RE: Read and count |
| Date | Thu, 10 Mar 2016 09:18:28 +0000 |
| Lines | 60 |
| Message-ID | <mailman.120.1457602470.15725.python-list@python.org> (permalink) |
| References | <2095750566.7009618.1457559033672.JavaMail.yahoo.ref@mail.yahoo.com> <2095750566.7009618.1457559033672.JavaMail.yahoo@mail.yahoo.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="us-ascii" |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de vtjyDAO/PnZo2LBjG2d1yQBoL7V0bkc7tMWuf7yIO4Gw== |
| Return-Path | <Joaquin.Alzola@lebara.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.016 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'python)': 0.05; 'val': 0.07; 'cc:addr:python-list': 0.09; 'learner': 0.09; 'observation': 0.09; 'python': 0.10; 'message-----': 0.15; '(moving': 0.16; '2016': 0.16; 'open(file)': 0.16; 'privilege.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:[ 60': 0.16; 'string': 0.17; '2001': 0.18; 'all,': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'trying': 0.22; 'header:In-Reply- To:1': 0.24; 'str': 0.29; 'print': 0.30; 'url:mailman': 0.30; 'code': 0.30; 'url:python': 0.33; 'open': 0.33; 'skip:- 10': 0.34; 'url:listinfo': 0.34; 'file': 0.34; 'add': 0.34; 'sent:': 0.35; 'city.': 0.35; 'subject:': 0.35; 'but': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'thanks': 0.37; 'charset:us-ascii': 0.37; 'list.': 0.37; 'starting': 0.37; 'data': 0.39; 'from:': 0.39; 'url:mail': 0.40; 'field': 0.60; 'march': 0.64; 'city': 0.65; 'contact': 0.66; 'python-list': 0.66; 'email name:python-list': 0.67; 'subject': 0.70; 'disclose': 0.71; '2002': 0.79; 'to:addr:yahoo.com': 0.80; 'received:104': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=lebara.onmicrosoft.com; s=selector1-lebara-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=8rQOfg7OeySdA2AXyW59RshjspCnz2dfptmTTelkRr4=; b=Hvc0/BNPoALEg2G1vSfstOgJS69H5udsyoZOaDUx0tl5ZC6jsP1XdBdpsmWcxRtHK2w0sPHEhnjFbwFRMkjGSZ3SyyWbJqGyxHk0AwObJ3g2XJshqp9mnFGvwdD/t4rQfajhJpGM9O4eR7jObhJug2N3ZMlHiox6+K3jMUIYUTA= |
| Thread-Topic | Read and count |
| Thread-Index | AQHReqhaF3xqe5xTO0G2XlQVY5rHqZ9SZIaQ |
| In-Reply-To | <2095750566.7009618.1457559033672.JavaMail.yahoo@mail.yahoo.com> |
| Accept-Language | en-GB, en-US |
| Content-Language | en-US |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| authentication-results | yahoo.com; dkim=none (message not signed) header.d=none;yahoo.com; dmarc=none action=none header.from=lebara.com; |
| x-originating-ip | [165.225.80.109] |
| x-ms-office365-filtering-correlation-id | 8d6196d9-659f-4f86-ae5d-08d348c4f0fd |
| x-microsoft-exchange-diagnostics | 1; DB5PR07MB1496; 5:Yjz73gnKn0C5L7xWwJj3xEwG+nHeQSYgBtcaHWAO9DRy9UraDpXutsEtyEnP2q8HYdmP3op2NsQtK2N+Y2RbnHKyv7U6x1nDoF0OdFehm5JPECeFiSaBBhziEm3iE0I20X3PFmSjAJbKWVLwMF4g+w==; 24:Br5EByHut6WEXa0t4oihfGe/EYU15nA8KbFYM8TBp83X4+eNbWpzKnTF9HsdfjA1W1qN9AUfSNP6fLbmExgj7gT1lhn+ZdHMwBffSXm8DJg= |
| x-microsoft-antispam | UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR07MB1496; |
| x-microsoft-antispam-prvs | <DB5PR07MB149653FC2447F02EC611C15EF0B40@DB5PR07MB1496.eurprd07.prod.outlook.com> |
| x-exchange-antispam-report-test | UriScan:; |
| x-exchange-antispam-report-cfa-test | BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:DB5PR07MB1496; BCL:0; PCL:0; RULEID:; SRVR:DB5PR07MB1496; |
| x-forefront-prvs | 08770259B4 |
| x-forefront-antispam-report | SFV:NSPM; SFS:(10019020)(6009001)(13464003)(66654002)(53754006)(76576001)(19580395003)(87936001)(19580405001)(586003)(5002640100001)(2521001)(122556002)(77096005)(5003600100002)(15975445007)(11100500001)(81166005)(2906002)(92566002)(3660700001)(3846002)(6116002)(1220700001)(50986999)(5008740100001)(1096002)(3480700003)(4326007)(102836003)(2900100001)(110136002)(33656002)(106116001)(76176999)(54356999)(2950100001)(189998001)(10400500002)(86362001)(3280700002)(5004730100002)(66066001)(74316001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB5PR07MB1496; H:DB5PR07MB1496.eurprd07.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; |
| spamdiagnosticoutput | 1:23 |
| spamdiagnosticmetadata | NSPM |
| X-OriginatorOrg | lebara.com |
| X-MS-Exchange-CrossTenant-originalarrivaltime | 10 Mar 2016 09:18:28.2381 (UTC) |
| X-MS-Exchange-CrossTenant-fromentityheader | Hosted |
| X-MS-Exchange-CrossTenant-id | d7093539-83cd-4991-b1b3-aacef74cf097 |
| X-MS-Exchange-Transport-CrossTenantHeadersStamped | DB5PR07MB1496 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:104495 |
Show key headers only | View raw
Try to do a .split(' ') and then add field 0 and 1 to an list.
For open the file you can do it easier:
with open(file) as f:
for line in f:
print('line')
-----Original Message-----
From: Python-list [mailto:python-list-bounces+joaquin.alzola=lebara.com@python.org] On Behalf Of Val Krem via Python-list
Sent: 09 March 2016 21:31
To: python-list@python.org
Subject: Read and count
Hi all,
I am a new learner about python (moving from R to python) and trying read and count the number of observation by year for each city.
The data set look like
city year x
XC1 2001 10
XC1 2001 20
XC1 2002 20
XC1 2002 10
XC1 2002 10
Yv2 2001 10
Yv2 2002 20
Yv2 2002 20
Yv2 2002 10
Yv2 2002 10
out put will be
city
xc1 2001 2
xc1 2002 3
yv1 2001 1
yv2 2002 3
Below is my starting code
count=0
fo=open("dat", "r+")
str = fo.read();
print "Read String is : ", str
fo.close()
Many thanks
--
https://mail.python.org/mailman/listinfo/python-list
This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
RE: Read and count Joaquin Alzola <Joaquin.Alzola@lebara.com> - 2016-03-10 09:18 +0000
csiph-web