Working with CSV data and iterating through a file - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Working with CSV data and iterating through a file (/thread-20464.html) |
Working with CSV data and iterating through a file - skoobi - Aug-12-2019 Hi. Im a complete noob and trying to learn the ropes. I thought id create a small project for myself that logs the amount of emails and phone calls I get in a day from a particular company. It runs through the terminal and it only has one user input which is 1. email and 2. phone. this then saves a record of the contact type and timestamp. I was recording this manually in a spreadsheet, but thought id build something for myself to make it a little easier and, well something fun to learn Python. The thing I'm not sure about is how to go through an old csv file that has a date, amount of email and calls for that day and import them into a new csv. For example... If the company calls me now, I run the python script press 2 and this logs the type of contact and timestamp. If i have 2 or 3 calls then i will have 2-3 records of this, which is fine as later on when I learn a bit more, I want to do some fun data stuff with it. worklog.csv 1,2019-08-11 10:39:33.612716 1,2019-08-11 10:40:49.213124 The csv i want to import though has a date and then an amount of emails or phone calls for that day. toimport.csv Date,Phone,Emails "Tuesday, 5 February 2019",4,10, "Wednesday, 6 February 2019",1,2, I was wondering how I'd go through each line of the csv file and say, there was 7 calls on wednesday then it loops and saves 7 calls in the worklog.csv file with the correct date. Thanks in advance. RE: Working with CSV data and iterating through a file - Gribouillis - Aug-13-2019 Which tutorial have you read about python's built-in csv module? |