Matlab Bulk Insert To SQL Question
Mostrar comentarios más antiguos
Hi,
I have a text file (comma-delimited) and (next-line row delimited) 10 x 116 (116 is the number of columns and were mapped to the corresponding fields/data types in the sql), I am trying to use the Matlab bulk insert, it was ok until I was given a file with NaN instead of Null for numerical data types. How can I handle the NaN values of type float or double from the textfile so that when it is inserted into the database table it is displayed as NULL.
exec(dbconn,['bulk insert ' Table_Name ' from '...
'''temp\FILENAME.txt'' with (fieldterminator = '','', '...
'rowterminator = ''\n'')']);
Thanks.
Respuestas (1)
Titus Edelhofer
el 17 de En. de 2014
0 votos
Hi,
you need to preprocess the data. So, use fopen/fread to read the full file (or large parts, if the file is huge) into memory as one string. Use strrep to replace the NaN by either nothing (empty) or 'null'. Use fopen/fwrite to write a new file. Read this into sql.
Titus
1 comentario
Categorías
Más información sobre String Parsing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!