Re: Load a CSV with different row lengths

2014-07-30 Thread Peter Otten
Miki Tebeka wrote: > Greetings, > >> I should've mentioned that I want to import my csv as a data frame or >> numpy array or as a table. > If you know the max length of a row, then you can do something like: > def gen_rows(stream, max_length): > for row in csv.reader(stream): >

Re: Load a CSV with different row lengths

2014-07-29 Thread Miki Tebeka
Greetings, > I should've mentioned that I want to import my csv as a data frame or numpy > array or as a table. If you know the max length of a row, then you can do something like: def gen_rows(stream, max_length): for row in csv.reader(stream): yield row + ([None] * (max_

Re: Load a CSV with different row lengths

2014-07-29 Thread Ryan de Vera
Hey skip, I should've mentioned that I want to import my csv as a data frame or numpy array or as a table. Best regards, Ryan On Tue, Jul 29, 2014 at 6:29 AM, Skip Montanaro wrote: > > How can I load this into python? I tried using both NumPy and Pandas. > > To add to Peter's response, I wou

Re: Load a CSV with different row lengths

2014-07-29 Thread Skip Montanaro
> How can I load this into python? I tried using both NumPy and Pandas. To add to Peter's response, I would be very surprised if numpy or Pandas couldn't be coaxed into loading your CSV file, but you didn't provide any details about what you expected and what you got. I've used Pandas to read CSV

Re: Load a CSV with different row lengths

2014-07-29 Thread Peter Otten
Ryan de Vera wrote: > I am trying to load a csv with different row lengths. For example, > > I have the csv > > a,b > a,b,c,d > a,b,c > > How can I load this into python? I tried using both NumPy and Pandas. The csv module in the standard library can deal with var

Load a CSV with different row lengths

2014-07-29 Thread Ryan de Vera
I am trying to load a csv with different row lengths. For example, I have the csv a,b a,b,c,d a,b,c How can I load this into python? I tried using both NumPy and Pandas. -- https://mail.python.org/mailman/listinfo/python-list