Python Forum
Working with CSV data and iterating through a file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working with CSV data and iterating through a file
#1
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.
Reply
#2
Which tutorial have you read about python's built-in csv module?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question apk file not working on android polya001 0 1,142 Feb-06-2022, 11:58 PM
Last Post: polya001
  Iterating Through Data Frame Rows JoeDainton123 2 2,901 Aug-09-2021, 07:01 AM
Last Post: Pedroski55
  Subprocess.Popen() not working when reading file path from csv file herwin 13 14,978 May-07-2021, 03:26 PM
Last Post: herwin
  xml file creation from an XML file template and data from an excel file naji_python 1 2,096 Dec-21-2020, 03:24 PM
Last Post: Gribouillis
  python3: iterating through list not working wardancer84 3 2,356 Jul-08-2020, 04:30 PM
Last Post: DPaul
  How to save CSV file data into the Azure Data Lake Storage Gen2 table? Mangesh121 0 2,101 Jun-26-2020, 11:59 AM
Last Post: Mangesh121
  Python File to EXE Not working. MianDoesCoding 9 6,789 Jun-09-2020, 08:21 AM
Last Post: MianDoesCoding
  Continuously iterating through a csv file ExplodingCoyote 2 3,662 Feb-26-2020, 07:56 AM
Last Post: DeaD_EyE
  Working with LibreOffice file FASB 0 1,984 Jun-13-2019, 01:23 PM
Last Post: FASB
  Working with large volume of data (RAM is not enough) evonevo 6 4,089 Oct-21-2018, 09:24 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020