Python Forum
Import CSV data into array and turn into integers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import CSV data into array and turn into integers
#1
Hey guys,

I am working on a school project and need to make it so that i can import data from a CSV file into an array and use it to do calculations. I am able to import the file but when i do it imports as strings. I also need that data in an array. This is what i have:
import csv 

x = []
y = []

with open('FinalData.csv') as csvfile:    
	csvReader = csv.reader(csvfile)    
	for row in csvReader:        
		x.append(row[0]), y.append(row[1])
        
print(x,y)
It will print the arrays but the number values will be strings. Any idea how to change?
Thanks for the help
Reply


Messages In This Thread
Import CSV data into array and turn into integers - by DoctorSmiles - Jul-16-2020, 12:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Plot a pandas data fram via pyqtgraph with an modul import and qt designer widget Nietzsche 0 869 May-29-2023, 02:42 PM
Last Post: Nietzsche
Video doing data treatment on a file import-parsing a variable EmBeck87 15 2,984 Apr-17-2023, 06:54 PM
Last Post: EmBeck87
  Python 3.11 data import question love0715 2 826 Mar-05-2023, 06:50 PM
Last Post: snippsat
  Can't import csv data JonWayn 4 1,437 Sep-18-2022, 02:07 AM
Last Post: JonWayn
  Seeing al the data in a dataframe or numpy.array Led_Zeppelin 1 1,171 Jul-11-2022, 08:54 PM
Last Post: Larz60+
Question Change elements of array based on position of input data Cola_Reb 6 2,179 May-13-2022, 12:57 PM
Last Post: Cola_Reb
  Reading data to python: turn into list or dataframe hhchenfx 2 5,423 Jun-01-2021, 10:28 AM
Last Post: Larz60+
  how to print all data from all data array? korenron 3 2,491 Dec-30-2020, 01:54 PM
Last Post: korenron
  I try to import data from Excel table to Word Template. NewbiePyPy 0 3,304 Oct-21-2020, 12:25 PM
Last Post: NewbiePyPy
  Turn coordinates in string into a tuple Kolterdyx 3 2,803 Jun-10-2020, 05:04 AM
Last Post: buran

Forum Jump:

User Panel Messages

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