Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV import for a DATE column results in "Something went wrong" displayed in firetable #219

Closed
mellissatort opened this issue Sep 24, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@mellissatort
Copy link

Describe the bug
A column in firetable is configured with the DATE type. When importing a CSV file with date data into this field, the result is "Something went wrong" is displayed. Several different date formats have been tried.

To Reproduce
Steps to reproduce the behavior:

  1. Create a firetable with a column of type DATE
  2. Import a csv file with a column having data in a date format into this DATE column. The following formats have been attempted:
  • m/d/yy
  • mm/dd/yy
  • mm/dd/yyyy
  • month day, yyyy
  • yyyy-mm-ddT00:00:00.000Z
  • yyyy-mm-ddT00:00:00Z
  1. The import will be successful but the firetable will display "Something went wrong" for this date value.

After manually entering a record into the firetable, we reviewed the data being stored via firebase and the date value is being stored as a timestamp instead of just a date. Exported the table data to confirm the format from an export and it is yyyy-mm-ddT00:00:00.000Z which is one of the formats listed above that was tried for importing.

Expected behavior
Firetable import will accept any date format, or a defined date format that is supported for import needs to be identified.

Desktop (please complete the following information):

  • OS: macOS 10.14.6
  • Browser: Safari
  • Version: 13.1
@notsidney notsidney added the bug Something isn't working label Oct 2, 2020
@grzegorzbialy
Copy link

grzegorzbialy commented Oct 2, 2020

I stumbled upon same issue while trying to import dates.
Until the issue is solved you can use onCreate trigger to correct the date.

Eg.:

exports.onSlotCreate = functions
  .firestore.document('docs/{docId}')
  .onCreate(async (snapshot, context) => {
    const docData = snapshot.data();
    let update = false;

    if (typeof docData.date === "string") {
      docData.date = new Date(docData.date);
      update = true;
    }

    if (update) {
      db.collection('docs').doc(snapshot.id).update({date: docData.date});
    }
  });

@mayurdhurpate
Copy link

@notsidney I think, all the fields are being imported as strings in the Firestore, and hence the Data Parser shows Something went wrong in the Date call.

I tried importing the following fields:

  • name : string
  • profilePictureUrl : string
  • rating : number
  • review : string
  • reviewId : string
  • timestamp : Date

with following csv:

name,profilePictureUrl,rating,review,reviewId,timestamp
Madhuri Salunkhe,,5,,temp_review,11/11/2020

Data Key Mapping Screen:

Screenshot 2020-10-08 at 7 59 21 PM

Firetable Post Import Screen

Screenshot 2020-10-08 at 7 59 54 PM

Actual Firestore Data Stored:

Screenshot 2020-10-08 at 8 00 08 PM

All the fields were directly added to Firestore as strings.

I think this could be the function which needs modification for type aware data importing.
https://github.com/AntlerVC/firetable/blob/fd036f59c7111b5105d69f94d183ccb1439eb0b7/www/src/components/Table/ImportCSV.tsx#L96-L105

notsidney added a commit that referenced this issue Oct 31, 2020
@notsidney
Copy link
Contributor

Hi everyone, thanks for letting us know about this bug. I’m working on a new Import CSV wizard UI, which includes parsing date columns. We’ll be using date-fns’ parseJSON function, which supports a bunch of formats similar to the ISO date string format. Please note that it assumes your date is in UTC time, so if your CSV’s date is not in UTC and your browser/system’s timezone is not UTC, Firetable (and Firestore) will display a different date/time value (converted from UTC to your local timezone).

👉 So before using the Import CSV feature, you must convert dates to UTC time and a supported format.

When rows are added, it will store dates as Firestore Timestamps, similar to adding a new row & inputting a date through the picker.

The new Import CSV wizard will be available as part of the next PR from develop to master.

notsidney added a commit that referenced this issue Oct 31, 2020
* feature/import-csv-v2:
  add date import warning
  update date-fns
  import CSV: parse dates (#219)
  show side drawer above import csv popover
  import, export: sort columns by index
  ImportCsvWizard: unmount on close
  finish ImportCsv wizard
  import CSV: step 2
  import CSV: step 1
  fix filename capitalisation
  import csv step 1
  add new ImportCSV upload/paste/url UI
  clean up ImportCSV
notsidney added a commit that referenced this issue Nov 1, 2020
* develop:
  v1.1.5
  cli: fix multiple commands not running on windows (#192)
  v1.1.5-0
  fix spawn yarn ENOENT?
  add date import warning
  update date-fns
  import CSV: parse dates (#219)
  show side drawer above import csv popover
  import, export: sort columns by index
  ImportCsvWizard: unmount on close
  finish ImportCsv wizard
  import CSV: step 2
  import CSV: step 1
  fix filename capitalisation
  fix cloud functions build breaking
  import csv step 1
  add new ImportCSV upload/paste/url UI
  clean up ImportCSV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants