Python Forum
Read data from a CSV file in S3 bucket and store it in a dictionary in python
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read data from a CSV file in S3 bucket and store it in a dictionary in python
#2
If use csv module and DictReader.
It will give you that structure bye default.
import csv

with open("log.csv") as f:
    records = csv.DictReader(f)
    for row in records:
         print(row)
Output:
{'name': 'xxx', 'origin': 'uk', 'dest': 'france'} {'name': 'yyyy', 'origin': 'norway', 'dest': 'finland'} {'name': 'zzzz', 'origin': 'denmark', 'dest': 'canada'}
Reply


Messages In This Thread
RE: Read data from a CSV file in S3 bucket and store it in a dictionary in python - by snippsat - May-14-2020, 10:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  dictionary output to text file (beginner) Delg_Dankil 2 1,262 Jul-12-2023, 11:45 AM
Last Post: deanhystad
  Using dictionary to find the most sent emails from a file siliusu 6 7,666 Apr-22-2021, 06:07 PM
Last Post: siliusu
  Updating dictionary in another py file tommy_voet 1 4,974 Mar-28-2021, 07:25 PM
Last Post: buran
  Making a dictionary from a file instyabam 0 1,534 Oct-27-2020, 11:59 AM
Last Post: instyabam
  how can i create a dictionary of dictionaries from a file Astone 2 2,304 Oct-26-2020, 02:40 PM
Last Post: DeaD_EyE
  Convert all actions through functions, fill the dictionary from a file Astone 3 2,489 Oct-26-2020, 09:11 AM
Last Post: DeaD_EyE
  Can we store value in file if we open file in read mode? prasanthbab1234 3 2,624 Sep-26-2020, 12:10 PM
Last Post: ibreeden
  [split] how to read a specific row in CSV file ? laxmipython 2 8,958 May-22-2020, 12:19 PM
Last Post: Larz60+
  Read text file, process data and print specific output Happythankyoumoreplease 3 2,968 Feb-20-2020, 12:19 PM
Last Post: jefsummers
  Store data in array kasper1903 4 3,162 Oct-04-2019, 12:43 PM
Last Post: kasper1903

Forum Jump:

User Panel Messages

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