chart icon indicating copy to clipboard operation
chart copied to clipboard

"TypeError: undefined is not an object" on csv and table import

Open joernroeder opened this issue 5 years ago • 7 comments

I'm getting a TypeError: undefined is not an object (evaluating 'Object.keys(a[0])') after pasting my 3 column table from Numbers in the following function:

function transpose(a) {
	return Object.keys(a[0]).map(function(c) {
		return a.map(function(r) { return r[c]; });
	});
}

I am also unable to load the .csv file directly, the plugin hands at the pink spinner then. Any suggestions what might be wrong? The csv is generated via https://www.npmjs.com/package/csv-writer

Sketch version: 62 chart version: 5.4.4

joernroeder avatar Jan 28 '20 22:01 joernroeder

Hi @joernroeder! Could you give me an example of table that you are trying to use and type of Chart?

pavelkuligin avatar Jan 28 '20 22:01 pavelkuligin

@pavelkuligin the chart type didnt matter. I was unable to a) upload (infinite loading) and b) paste the attached csv.

test.txt (I had to rename to .txt to upload it here)

joernroeder avatar Jan 29 '20 19:01 joernroeder

@joernroeder I've found a few issues, will fix them tomorrow and ship new release

pavelkuligin avatar Jan 30 '20 00:01 pavelkuligin

@joernroeder please update to Chart 5.4.5 and use this CSV: https://yadi.sk/d/xpaCKxTDkPECJw (your example had empty row at the end so it was an issue)

Ping me if you have any questions/problems

pavelkuligin avatar Jan 30 '20 23:01 pavelkuligin

@pavelkuligin thanks for looking into this. Empty lines at a file are pretty common, especially if you work with code and editors https://unix.stackexchange.com/questions/18743/whats-the-point-in-adding-a-new-line-to-the-end-of-a-file

I've testet 5.4.5 today and still noticed that I have to convert integers e.g. 8 to floats 8.0 to work properly when importing the csv directly. as soon as my source file had Integers in the data generation got stuck at the loading spinner.

joernroeder avatar Feb 03 '20 12:02 joernroeder

@joernroeder yep, I'm working on removing empty rows from CSV files.

Issue with integers is pretty strange, I will test it today and get back with clarifications

pavelkuligin avatar Feb 03 '20 12:02 pavelkuligin

@joernroeder I did some test and it works well: https://www.loom.com/share/244035d1e33146e0a8ee75f17a20e991

Maybe you see the spin for a long time because Sketch's performance is low with large amount of data

pavelkuligin avatar Feb 04 '20 19:02 pavelkuligin