Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #69393 > unrolled thread

writing reading from a csv or txt file

Started bymtcplumb@googlemail.com
First post2014-03-30 12:05 -0700
Last post2014-04-01 19:25 -0600
Articles 5 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  writing reading from a csv or txt file mtcplumb@googlemail.com - 2014-03-30 12:05 -0700
    Re: writing reading from a csv or txt file Jason Friedman <jsf80238@gmail.com> - 2014-03-30 14:19 -0600
    RE: writing reading from a csv or txt file "Joseph L. Casale" <jcasale@activenetwerx.com> - 2014-03-30 20:21 +0000
    Re: writing reading from a csv or txt file Gary Herron <gary.herron@islandtraining.com> - 2014-03-30 13:26 -0700
    Re: writing reading from a csv or txt file Jason Friedman <jsf80238@gmail.com> - 2014-04-01 19:25 -0600

#69393 — writing reading from a csv or txt file

Frommtcplumb@googlemail.com
Date2014-03-30 12:05 -0700
Subjectwriting reading from a csv or txt file
Message-ID<9023eae9-f814-40ac-9b84-043214e6b28f@googlegroups.com>
Hi I have 3 csv files with a list of 5 items in each.
rainfall in mm, duration time,time of day,wind speed, date.
I am trying to compare the files. cutting out items in list list. ie:- 
first file (rainfall2012.csv)rainfall, duration,time of day,wind speed,date.
first file (rainfall2013.csv)rainfall, duration,time of day,wind speed,date.
I would like to pick out maybe rainfalls and duration's and measure against say years. 
I would like to very the items from the rows. 
could you please advise me where i can find such information. or book, textbook.

[toc] | [next] | [standalone]


#69394

FromJason Friedman <jsf80238@gmail.com>
Date2014-03-30 14:19 -0600
Message-ID<mailman.8721.1396210791.18130.python-list@python.org>
In reply to#69393

[Multipart message — attachments visible in raw view] — view raw

>
> I am trying to compare the files. cutting out items in list list. ie:-
> first file (rainfall2012.csv)rainfall, duration,time of day,wind
> speed,date.
> first file (rainfall2013.csv)rainfall, duration,time of day,wind
> speed,date.
> I would like to pick out maybe rainfalls and duration's and measure
> against say years.
>
> Could you show us the first, say, three rows from each file, plus what you
would like the first three or six lines of output to be?

[toc] | [prev] | [next] | [standalone]


#69395

From"Joseph L. Casale" <jcasale@activenetwerx.com>
Date2014-03-30 20:21 +0000
Message-ID<mailman.8722.1396210964.18130.python-list@python.org>
In reply to#69393
> Hi I have 3 csv files with a list of 5 items in each.
> rainfall in mm, duration time,time of day,wind speed, date.
> I am trying to compare the files. cutting out items in list list. ie:-
> first file (rainfall2012.csv)rainfall, duration,time of day,wind speed,date.
> first file (rainfall2013.csv)rainfall, duration,time of day,wind speed,date.
> I would like to pick out maybe rainfalls and duration's and measure against
> say years.
> I would like to very the items from the rows.
> could you please advise me where i can find such information. or book,
> textbook.

How about we help you here..

So if you want to compare by year, you want to read all the rows in and perform
some math, because I can't help myself, I push this into sqlite at least but that's
probably overkill for you (besides the limitless benefits:)). You want to store some
state while you iterate over each row in the csv, appending data, then finally performing
some statistical math on the collection.

You will do this for each file, then finally aggregate your results.

jlc

[toc] | [prev] | [next] | [standalone]


#69396

FromGary Herron <gary.herron@islandtraining.com>
Date2014-03-30 13:26 -0700
Message-ID<mailman.8724.1396211717.18130.python-list@python.org>
In reply to#69393
On 03/30/2014 12:05 PM, mtcplumb@googlemail.com wrote:
> Hi I have 3 csv files with a list of 5 items in each.
> rainfall in mm, duration time,time of day,wind speed, date.
> I am trying to compare the files. cutting out items in list list. ie:-
> first file (rainfall2012.csv)rainfall, duration,time of day,wind speed,date.
> first file (rainfall2013.csv)rainfall, duration,time of day,wind speed,date.
> I would like to pick out maybe rainfalls and duration's and measure against say years.
> I would like to very the items from the rows.
> could you please advise me where i can find such information. or book, textbook.
>

How is this a Python question?

There is a standard  module included with Python for reading CSV files.  
Would you like to know how to use that?  You can find documentation on 
it here:
     http://docs.python.org/3/library/csv.html

Gary Herron

[toc] | [prev] | [next] | [standalone]


#69528

FromJason Friedman <jsf80238@gmail.com>
Date2014-04-01 19:25 -0600
Message-ID<mailman.8809.1396401953.18130.python-list@python.org>
In reply to#69393

[Multipart message — attachments visible in raw view] — view raw

>
> Hi jason thanks for replying.Below is a typical file return.To you I've no
> doubt this is a simple problem but,to a beginner like me it just seems I
> lack the understanding of how to split out the items in a list.Thanks again
> for looking at it.
> Rainfall,duration,TimeStart,windspeed,Date
> 0.1,5,05:25,3.1,03/02/2013
> 0.12,8,11:20,4.1,03/02/2013
> 0.1,2,18:05,2.8,03/02/2013
> 18,15,04:03,4.5,04/02/2013
> 2.3,6,17:02,2.4,04/02/2013
> ***********************************************
> Rainfall,duration,TimeStart,windspeed,Date
> 1.1,5,05:25,3.1,014/02/2012
> 1.32,8,14:20,4.1,14/02/2012
> 2.1,2,22:00,2.8,14/02/2012
> 18,15,03:30,4.5,18/02/2012
> 1.3,4,13:00,2.4,18/02/2012
>
>
> I am trying to compare the files. cutting out items in list list. ie:-
>>> first file (rainfall2012.csv)rainfall, duration,time of day,wind
>>> speed,date.
>>> first file (rainfall2013.csv)rainfall, duration,time of day,wind
>>> speed,date.
>>> I would like to pick out maybe rainfalls and duration's and measure
>>> against say years.
>>>
>>>
>> Ok, now show us the first few lines of the output you are wanting (please
remember to add you answer at the bottom, not the top).
Please also remember to reply-all.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web