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,478 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,840 points

Related Questions In Python

0 votes
1 answer

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

with open(fname) as f:     content = f.readlines() # you ...READ MORE

answered Oct 9, 2018 in Python by SDeb
• 13,300 points
1,791 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
869 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,840 points
6,409 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,840 points
822 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,837 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,770 points
524 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,840 points
965 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,840 points
4,526 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