473,378 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

CSV Issues

Hello,
I'm working on a script which collects some data and puts into a csv
file which could be exported to excel.
so far so good, I'm able to do what I described.
When I run the script for the second time after a certain period of
time the results should appear next to the results of the last run,
I'm unable to make a new column when the script is run after the first
time.
Ideally I would like to have an output which looks like this.
1/20 1/27
we.py we.py
gh.py gj.py <- Indicating tht the file has changed
fg.py fg.py

Please help me out.
Thanks

Jul 19 '07 #1
1 961
Hi,

On Thu, 19 Jul 2007 06:59:24 +0200, Rohan <vo********@gmail.comwrote:
When I run the script for the second time after a certain period of
time the results should appear next to the results of the last run,
I'm unable to make a new column when the script is run after the first
time.
Ideally I would like to have an output which looks like this.
1/20 1/27
we.py we.py
gh.py gj.py <- Indicating tht the file has changed
fg.py fg.py
Try something like this:
>>import csv
f = open("/tmp/data.csv", "rb")
reader = csv.reader(f)
headings = reader.next()
headings
['1/20']
>>rows = []
for row in reader:
.... rows.append(row)
....
>>rows
[['we.py'], ['gh.py'], ['fg.py']]
>>f.close()
headings.append("1/27")
rows[0].append("we.py")
rows[1].append("gj.py")
rows[2].append("fg.py")
f = open("/tmp/data.csv", "wb")
writer = csv.writer(f)
writer.writerow(headings)
writer.writerows(rows)
f.close()
Regards
Lutz
Jul 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: malcolm | last post by:
Hello, We have a robust (.NET 1.1 c# winforms) client-server application that utilizes many typed DataSets, typed DataTables and typed DataRows. Our application is a series of windows and popup...
2
by: malcolm | last post by:
Hello, We have a robust (.NET 1.1 c# winforms) client-server application that utilizes many typed DataSets, typed DataTables and typed DataRows. Our application is a series of windows and popup...
1
by: GaryDean | last post by:
We have been developing all of our .net applications on 32 bit windows using 32 bit SQL Server. We are being asked to now deploy to servers running 64bit windows and 64bit SQL Server. Are there...
3
by: eschneider | last post by:
Just some common issues with WS: Using custom objects: When objects change, seems you are always fixing some issue. Update references, which sometimes does not work. Deployment: Weird errors...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.