Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSV Import of array for matrix

See original GitHub issue

I created a matrix array in a CSV file as I needed to make the array for ~500 different points that may need to change on a bi-monthly basis, so csv file feels like the best way to maintain this as opposed to manually creating and updating it within

I used numpy and pandas to read the file and create the array, no problem; however when it spits out the array it looks like this: matrix = [ [1 0 0 0 1] ]

instead of matrix = [ [1, 0, 0, 0, 1] ]

Which returns an error when you try to run it through the portion of your script. As best as I can understand it the script requires the commas to be associated to a list type of format, not an array of numbers; or what maybe considered a tuple.

Would it be possible to add in this sort of functionality? I have looked into the articles below to best resolve the issue but my understanding of python is too limited to understand the greater problem nor how to implement it into the code you have already created. Grid from counting points CSV appending rows option

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

breancommented, Dec 27, 2017

The python-print for numpy does not print commas, but the print is just a visual representation, so it does not say anything about the internal data structure if there is a comma or not. I think it should be possible to use numpy arrays so I will investigate and reopen this issue. Can you provide me with the non-working code and/or error message?

mwtiltoncommented, Feb 10, 2018

Yes this fixed the problem. Sorry for late reply, got side-tracked on other porjects xD Thansk for the help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Read CSV Into 2D Array - Linux Hint
In this method, we are going to use the numpy.genfromtxt () method which converts the CSV data into a 2D array. The below...
Read more >
csv-to-array-matrix - npm
A simple CVS to Matrix parser - reads a CSV file, outputs an arrays in array (Matrix). Installation. npm install csv-to-array-matrix ...
Read more >
load csv into 2D matrix with numpy for plotting - Stack Overflow
import csv import numpy reader = csv.reader(open("test.csv", "rb"), delimiter=",") x = list(reader) result = numpy.array(x).astype("float").
Read more >
How to create matrix and vector from CSV file in R
In this article, we will discuss how to convert CSV data into a matrix and a vector in R Programming Language. We will...
Read more >
CSVIMPORT - File Exchange - MATLAB Central - MathWorks
CSVIMPORT reads the specified CSV file and stores the contents in a cell array or matrix. 4.9. (38). 22.9K Downloads.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found