Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > intermediate python csv reader/writer question from a beginner

Reply
Thread Tools

intermediate python csv reader/writer question from a beginner

 
 
Learning Python
Guest
Posts: n/a
 
      02-23-2009
anything related to csv, I usually use VB within excel to manipulate
the data, nonetheless, i finally got the courage to take a dive into
python. i have viewed a lot of googled csv tutorials, but none of
them address everything i need. Nonetheless, I was wondering if
someone can help me manipulate the sample csv (sample.csv) I have
generated:

,,
someinfo,,,,,,,
somotherinfo,,,,,,,
SEQ,Names,Test1,Test2,Date,Time,,
1,Adam,1,2,Monday,1:00 PM,,
2,Bob,3,4,Monday,1:00 PM,,
3,Charlie,5,6,Monday,1:00 PM,,
4,Adam,7,8,Monday,2:00 PM,,
5,Bob,9,10,Monday,2:00 PM,,
6,Charlie,11,12,Monday,2:00 PM,,
7,Adam,13,14,Tuesday,1:00 PM,,
8,Bob,15,16,Tuesday,1:00 PM,,
9,Charlie,17,18,Tuesday,1:00 PM,,

into (newfile.csv):

Adam-Test1,Adam-Test2,Bob-Test1,Bob-Test2,Charlie-Test1,Charlie-
Test2,Date,Time
1,2,3,4,5,6,Monday,1:00 PM
7,8,9,10,11,12,Monday,2:00 PM
13,14,15,16,17,18,Tuesday,1:00 PM

note:
1. the true header doesn't start line 4 (if this is the case would i
have to use "split"?)
2. if there were SEQ#10-12, or 13-15, it would still be Adam, Bob,
Charlie, but with different Test1/Test2/Date/Time
 
Reply With Quote
 
 
 
 
Chris Rebert
Guest
Posts: n/a
 
      02-24-2009
On Mon, Feb 23, 2009 at 1:33 PM, Learning Python <(E-Mail Removed)> wrote:
> anything related to csv, I usually use VB within excel to manipulate
> the data, nonetheless, i finally got the courage to take a dive into
> python. i have viewed a lot of googled csv tutorials, but none of
> them address everything i need. Nonetheless, I was wondering if
> someone can help me manipulate the sample csv (sample.csv) I have
> generated:


For reading and writing CSV files, see the `csv` module in the
standard library (http://docs.python.org/library/csv.html).

Cheers,
Chris

--
Follow the path of the Iguana...
http://rebertia.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
intermediate/beginner question on classes pauldepstein@att.net C++ 1 07-24-2007 08:47 AM
intermediate/beginner question on classes pauldepstein@att.net C++ 1 07-24-2007 08:44 AM
Is 7MP too much for a beginner (intermediate) camera? Susan P Digital Photography 26 12-20-2005 05:50 PM
Need to locate beginner/intermediate training course in the UK SarahEmmm Perl Misc 4 12-06-2004 11:49 PM



Advertisments