I'm trying to export some data from MsSQL to a CSV file using sqsh.
Assuming the SQL statement is SELECT * from [dbo].[searchengines].
The resulting CSV is something like these,
field1,field2,field3,field4,field5
,,"Google",,
,,"Yahoo",,
,,"Altavista",,
,,"Lycos",,
What can I do to make it into something like these :
field1,field2,field3,field4,field5
NULL,NULL,"Google",NULL,NULL
NULL,NULL,"Yahoo",NULL,NULL
NULL,NULL,"Altavista",NULL,NULL
NULL,NULL,"Lycos",NULL,NULL
I basically want to change fields that are empty into NULL. Any idea?
Unfortunately the empty string in csv output for nullable columns is hard coded in sqsh. See src/dsp_csv.c on line 144 where the call is made:
You could replace it by
and rebuild sqsh. In the next release I will come up with a more elaborate solution.