Problem uploading and using a CSV file


I am using the cfs:standard-packages and cfs:filesystem packages to upload a CSV file. Then, I want to process the data via D3.

I get a file uploaded, but when I try to parse it using D3, the file has a lot of mark up stuff (it’s not a text file anymore).

I tried another approach and it was to read a CSV from a URL. With D3 I can do that directly except that in my case I had a CORS issue. So, I tried using the HTTP package and then pass the result to the client site to continue working with D3. However i got exactly the same problem: the data has a lot of markup stuff.

Is there a way to indicate to either one or both methods I am trying that the data is text or CSV?


It’s been so long since this problem but I’ve not found solution. Program does not see CSV (and other like TSV etc) files :frowning:


As long as the MIME type is set correctly in the response header from the URL, you should be able to parse CSV content with

const result = HTTP.get(url);
csv = result.content; // for raw csv, or
csv = result.content.split(/\r/); // convert to array, one row per line


I just read in a CSV file like a “regular” flat file. Then use Papa Parse to parse it:

	//  --  read the file  --  //

	let reader = new FileReader() ;

	reader.onerror = ( error ) => {
		alert( "Error Occured While Loading Table Specification Spreadsheet. ERROR=" + error.message ) ;

	reader.readAsText( specfile ) ;    //  read in csv data to specfile

	//  --  papa parse it  --  //

	Papa.parse( specfile, {   //  get each line
		header: true ,
		dynamicTyping: true ,
		complete: ( results ) => {

			//  **  --  TABLE SPECS FROM SPREADSHEET IN SESSION VAR csvResults  --  **  //

			Session.set( "csvResults", results ) ;