Skip to content

NULL value imported from CSV file become empty string #195

Closed

Description

@harysutanto

OS : OS X 10.10.2
SQLitebrowser Version : Feb 06, 2015 nightlies

It is as the title suggests, null value is become empty string when I tried to import from CSV file which has a null value (etc,10,,10,). I tried to import using other SQLite app the null value (etc,10,,10,) become NULL instead of empty string. Oh, and the preview when importing a CSV file (after choosing the CSV file) btw, also display an empty string rather than NULL value. I have already checked when I import using SQLitebrowser and open with another app it becomes empty string for the NULL value.

I don't know if this is a feature or not, but maybe you can add an option when trying to import you give a checkbox and textfield for the NULL value, so when the user check the box but leaves the textfield empty the NULL value becomes empty string or the value of the textfield if any. And when the user does not check the box, the textfield is disabled and the null value becomes NULL when imported.

Preview screenshot:
screen shot 2015-02-06 at 10 28 08 pm

After import screenshot:
screen shot 2015-02-06 at 10 28 59 pm

Browse table data using another app after import from CSV using SQLitebrowser:
screen shot 2015-02-06 at 11 01 18 pm

Browse table data using SQLitebrowser after import using other SQL app:
screen shot 2015-02-06 at 10 32 32 pm

In case you need the CSV file, here it is:
https://www.dropbox.com/s/e8pad14efeki5e7/ZWATCHACTIVITY.csv?dl=0

Activity

  1. harysutanto commented on Feb 7, 2015

    @harysutanto
    Author

    On second try, I think when importing from a CSV data to current table that exist in the sqlite database ignores whatever default value the table has. Maybe this is why, when importing from a CSV the value of the table become empty cell rather than the table default value NULL.

    I already tried using other default value other than NULL, and the result is also an empty cell rather than default value.

  2. rp- commented on Feb 7, 2015

    @rp-
    Contributor

    Well I can live with the argument that an empty: ',,' column should NULL and if you want a empty string the CSV data should be ',"",'.
    But to get default values for columns is a bit more tricky and maybe not always what a user would expect or want. And usually it shouldn't be such a problem to get default values you want into the csv data. e.g. with libreoffice calc or excel.

  3. justinclift commented on Mar 12, 2015

    @justinclift
    Member

    Thinking through this a bit, its pretty straightforward (to me atm 😉), that a field consisting of only two single quotes, should be an empty string. eg:

    • '','other stuff'
    • 1,'',13
    • 1,2,''

    Also, a field with only NULL in it (unquoted) is very likely meant to be a NULL. eg:

    • NULL,1,2
    • 1,NULL,2
    • 3,4,NULL

    Though section 2.6 of RFC 4180 does indicate it could also be considered a string value of "NULL". 😦

    A field without a value though...yeah, that's interesting. NULL or "default field value" are both possibilities.

    At the risk of making things more complicated, we may need another option added to our cvs import dialog. ...sigh...

  4. harysutanto commented on Mar 12, 2015

    @harysutanto
    Author

    Yes, actually I also prefer to have an option for what to do with the empy value (',,') than to set the field to default value by default.

    Anyway, Thanks for the responses and keep up the good work!

  5. justinclift commented on Jan 7, 2016

    @justinclift
    Member

    Just tested CSV import with our new 3.8.0 release. We still need to add that extra option to the CSV import dialog, to specify what happens to fields without values.

    It should be a very simple bit of coding, if someone has time to get it done. @MKleusberg maybe? 😄

  6. justinclift commented on Aug 4, 2016

    @justinclift
    Member

    @revolter This "adding an extra option to the CSV import dialog" seems like it might be your kind of thing. Want to take a look at it?

  7. revolter commented on Aug 4, 2016

    @revolter
    Member

    @justinclift, If only I would know how to branch based on the setting.

  8. justinclift commented on Aug 4, 2016

    @justinclift
    Member

    The database interaction bit could be tricky at the moment, yeah. 😦

  9. justinclift commented on Jun 27, 2017

    @justinclift
    Member

    @lhunsicker Unfortunately... we haven't put much/any time into this yet. We will "at some point"... but it hasn't happened yet. ☹️

  10. MKleusberg commented on Jun 29, 2017

    @MKleusberg
    Member

    @lhunsicker Hi Larry, yeah we're currently drowning in issues, so nobody put any effort into this. But thanks for reminding us 😉 I've just made an (experimental) change to the CSV import that implements your suggestion on this. If you're importing into an existing table (if you're not we can't really make any assumptions about data types) and the importer hits an empty field in the CSV file it now checks the data type of the field. If it is numeric it will insert 0 or NULL (depending on the NOT NULL flag of the field). If it isn't numeric it is still going to insert an empty string.
    Are you ok to download and test tomorrow's nightly build (see our main page for the link) and report back if it is improving the situation for you? 😄

  11. 10 remaining items

  12. justinclift commented on Jul 2, 2017

    @justinclift
    Member

    Hmm, with this:

    How can I contact them to pass on my concern about NULL csv values being typed as text empty strings?

    It's a bit unclear (to me) who the "them" you're meaning are. 😉

    If you're meaning the developers of the SQLite3 bash shell, then definitely reach out to them on the "sqlite-users" mailing list as a first step. They're pretty friendly too, so it should be a fairly easy experience.

        http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

    Does that help? 😄

  13. chrisjlocke commented on Jul 8, 2017

    @chrisjlocke
    Member

    Its not very clear, but when you create a new issue, you are meant to type after the right pointing arrow.

    image

    The arrows are actually HTML markers to put comments, and anything put between these markers are ignored. Unfortunately, your comment was between these markers. I amended your last query, so it should show up now. 👍

    Hope that helps. 🚁

  14. PeterSmyth12 commented on Dec 20, 2017

    @PeterSmyth12

    Using the 20th December 2017 release (Windows x64)
    Importing a table into an already defined schema still does not treat a missing value as NULL but as an empty string ''.
    Even if the field has been defined as REAL and defined as NOT NULL it gets the empty string.

    Is there any chance that this is going to get fixed soon?

  15. MKleusberg commented on Jul 14, 2018

    @MKleusberg
    Member

    Sorry for the delay but this feature is now added to the CSV import. If there is no value in a CSV field there are now four possible actions in the import:

    1. If there is a default value for this column, we use that (you can disable this option however)
    2. If the column allows NULL values, we insert a NULL value
    3. If the field is numeric, we insert a 0
    4. Only in the other cases we insert an empty string

    If you're still interested in this, please check the nightly builds and let me know if it's working as expected for you, @harysutanto, @lhunsicker and @PeterSmyth12 😄

  16. MKleusberg commented on Jul 14, 2018

    @MKleusberg
    Member

    Also, the import should be much faster now 😉

  17. MKleusberg commented on Aug 16, 2018

    @MKleusberg
    Member

    Closing this because the issue should be solved and we haven't heard back from the reporters for a while. If you feel like I closed this issue too early, feel free to re-open it - I'd be happy to hear any more ideas or opinions about this 😄

  18. self-assigned this
    on Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions