@@ -51,8 +51,13 @@ import { CsvInputOptions, CsvOutputOptionsNode } from "../types"
5151const $readCSV = async ( filePath : string , options ?: CsvInputOptions ) : Promise < DataFrame > => {
5252 if ( filePath . startsWith ( "http" ) || filePath . startsWith ( "https" ) ) {
5353 return new Promise ( resolve => {
54+ const optionsWithDefaults = {
55+ header : true ,
56+ ...options ,
57+ }
58+
5459 const dataStream = request . get ( filePath ) ;
55- const parseStream : any = Papa . parse ( Papa . NODE_STREAM_INPUT , options ) ;
60+ const parseStream : any = Papa . parse ( Papa . NODE_STREAM_INPUT , optionsWithDefaults ) ;
5661 dataStream . pipe ( parseStream ) ;
5762
5863 const data : any = [ ] ;
@@ -69,6 +74,7 @@ const $readCSV = async (filePath: string, options?: CsvInputOptions): Promise<Da
6974 return new Promise ( resolve => {
7075 const fileStream = fs . createReadStream ( filePath )
7176 Papa . parse ( fileStream , {
77+ header : true ,
7278 ...options ,
7379 complete : results => {
7480 const df = new DataFrame ( results . data ) ;
@@ -97,10 +103,14 @@ const $readCSV = async (filePath: string, options?: CsvInputOptions): Promise<Da
97103const $streamCSV = async ( filePath : string , callback : ( df : DataFrame ) => void , options ?: CsvInputOptions ) : Promise < null > => {
98104
99105 if ( filePath . startsWith ( "http" ) || filePath . startsWith ( "https" ) ) {
106+ const optionsWithDefaults = {
107+ header : true ,
108+ ...options ,
109+ }
100110 return new Promise ( resolve => {
101111 let count = - 1
102112 const dataStream = request . get ( filePath ) ;
103- const parseStream : any = Papa . parse ( Papa . NODE_STREAM_INPUT , options ) ;
113+ const parseStream : any = Papa . parse ( Papa . NODE_STREAM_INPUT , optionsWithDefaults ) ;
104114 dataStream . pipe ( parseStream ) ;
105115
106116 parseStream . on ( "data" , ( chunk : any ) => {
@@ -119,6 +129,7 @@ const $streamCSV = async (filePath: string, callback: (df: DataFrame) => void, o
119129 return new Promise ( resolve => {
120130 let count = - 1
121131 Papa . parse ( fileStream , {
132+ header : true ,
122133 ...options ,
123134 step : results => {
124135 const df = new DataFrame ( [ results . data ] , { index : [ count ++ ] } ) ;
0 commit comments