How do I read CSV data into a record array in NumPy

0 votes
I wonder if there is a direct way to import the contents of a CSV file into a record array, much in the way that R's read.table(), read.delim(), and read.csv() family imports data to R's data frame?
Jun 22, 2020 in Python by kartik
• 37,520 points
3,457 views

1 answer to this question.

0 votes

Hello @kartik,

You can use Numpy's genfromtxt() method to do so, by setting the delimiter kwarg to a comma.

from numpy import genfromtxt
my_data = genfromtxt('my_file.csv', delimiter=',')

Hope this is helpful!!
Thank You!!

answered Jun 22, 2020 by Niroj
• 82,880 points

Related Questions In Python

0 votes
2 answers

In Python, how do I read a file line-by-line into a list?

readline function help to  read line in ...READ MORE

answered Jun 21, 2020 in Python by sahil
• 580 points
1,763 views
0 votes
1 answer

How do I turn a list into numpy array?

Use this line: numpy_array = np.array(list) And printing/displaying the ...READ MORE

answered May 24, 2019 in Python by Isha
852 views
–1 vote
2 answers
0 votes
1 answer

Error:urllib and “SSL: CERTIFICATE_VERIFY_FAILED”

Hello @kartik, Insert this code at the beginning ...READ MORE

answered Jun 5, 2020 in Python by Niroj
• 82,880 points
6,384 views
0 votes
1 answer

How to manage local vs production settings in Django?

Hello @kartik, In settings.py: try: from local_settings ...READ MORE

answered Jun 22, 2020 in Python by Niroj
• 82,880 points
810 views
0 votes
1 answer

Installing Selenium Webdriver with Python package

Hey Hemant, for installing Selenium Webdriver with ...READ MORE

answered May 8, 2019 in Selenium by Anvi
• 14,150 points
15,775 views
0 votes
1 answer

What is selenium in python?

It is known as Web automations, It is ...READ MORE

answered Nov 4, 2020 in Python by Gitika
• 65,890 points
508 views
0 votes
1 answer

How do I merge two dictionaries in a single expression in Python?

Hello, For dictionaries x and y, z becomes a shallowly merged dictionary with ...READ MORE

answered Apr 13, 2020 in Python by Niroj
• 82,880 points
927 views
+1 vote
1 answer

How to convert a PIL Image into a numpy array?

Hello @kartik, You just need to convert your ...READ MORE

answered Jun 22, 2020 in Python by Niroj
• 82,880 points
4,480 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP