Matlab Bulk Insert To SQL Question
Mostra commenti meno recenti
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.
Risposte (1)
Titus Edelhofer
il 17 Gen 2014
0 voti
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 Commento
Categorie
Scopri di più su String Parsing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!