File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,26 +116,33 @@ export function useInstrumentVisualization({ params }: UseInstrumentVisualizatio
116116 } ) ;
117117 } ;
118118
119+ const parseHelper = ( rows : unknown [ ] , delimiter : string ) => {
120+ return unparse ( rows , {
121+ delimiter : delimiter ,
122+ escapeChar : '"' ,
123+ header : true ,
124+ quoteChar : '"' ,
125+ quotes : false ,
126+ skipEmptyLines : true
127+ } ) ;
128+ } ;
129+
119130 switch ( option ) {
120131 case 'CSV' :
121132 void download ( `${ baseFilename } .csv` , ( ) => {
122133 const rows = makeWideRows ( ) ;
123134
124- const csv = unparse ( rows , {
125- delimiter : ',' ,
126- escapeChar : '"' ,
127- header : true ,
128- quoteChar : '"' ,
129- quotes : false ,
130- skipEmptyLines : true
131- } ) ;
135+ const csv = parseHelper ( rows , ',' ) ;
132136
133137 return csv ;
134138 } ) ;
135139 break ;
136140 case 'CSV Long' : {
137- const rows = makeLongRows ( ) ;
138- console . log ( rows ) ;
141+ void download ( `${ baseFilename } .csv` , ( ) => {
142+ const rows = makeLongRows ( ) ;
143+ const csv = parseHelper ( rows , ',' ) ;
144+ return csv ;
145+ } ) ;
139146 break ;
140147 }
141148 case 'JSON' : {
@@ -149,19 +156,19 @@ export function useInstrumentVisualization({ params }: UseInstrumentVisualizatio
149156 void download ( `${ baseFilename } .tsv` , ( ) => {
150157 const rows = makeWideRows ( ) ;
151158
152- const tsv = unparse ( rows , {
153- delimiter : '\t' ,
154- escapeChar : '"' ,
155- header : true ,
156- quoteChar : '"' ,
157- quotes : false ,
158- skipEmptyLines : true
159- } ) ;
159+ const tsv = parseHelper ( rows , '\t' ) ;
160160
161161 return tsv ;
162162 } ) ;
163163 break ;
164164 case 'TSV Long' :
165+ void download ( `${ baseFilename } .tsv` , ( ) => {
166+ const rows = makeLongRows ( ) ;
167+
168+ const tsv = parseHelper ( rows , '\t' ) ;
169+
170+ return tsv ;
171+ } ) ;
165172 break ;
166173 }
167174 } ;
You can’t perform that action at this time.
0 commit comments