Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Store data in array
#1
Hi guys.

I have some trouble with this code. I want to store my data from a csv into an array - The data consist both of text, dates and numbers.

import csv

timestamp = []
shoeSize = []
program = []
height = []
why = []

with open('Data.csv', delimiter=';') as f:
    reader = csv.reader(f)
    for row in reader:
        timestamp.append[row[0]]
        shoeSize.append[row[1]]
        program.append[row[2]]
        height.append[row[3]]
        why.append[row[4]]

print(timestamp)
It returns the mistake: value is unsubscriptable python

As I understand, it is because of the different types of datapoint it tries to store and it can only stores floats?
How would you guys store data in an array, if it consist of different datatypes ?

Thank you :)
Reply


Messages In This Thread
Store data in array - by kasper1903 - Oct-01-2019, 03:34 PM
RE: Store data in array - by ichabod801 - Oct-01-2019, 03:49 PM
RE: Store data in array - by kasper1903 - Oct-04-2019, 10:32 AM
RE: Store data in array - by ichabod801 - Oct-04-2019, 12:37 PM
RE: Store data in array - by kasper1903 - Oct-04-2019, 12:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Newbie here. Create an array from file data? Rayj00 2 1,243 Jan-13-2023, 01:35 PM
Last Post: perfringo
  Read data from a CSV file in S3 bucket and store it in a dictionary in python Rupini 3 6,995 May-15-2020, 04:57 PM
Last Post: snippsat
  Using Data from an Array Tomington 1 2,391 Apr-06-2019, 10:42 AM
Last Post: perfringo
  Call out data from 2D array to perform calculation poonck1 1 3,313 Feb-28-2017, 01:53 PM
Last Post: buran
  How to extract two data types from a text file and store them as two separate lists banf 1 3,486 Jan-16-2017, 09:52 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