0

Please would you help me out with this error.

I am trying to Import trough wizzard a csv file, downloaded here https://ourworldindata.org/covid-deaths But unfortunately it is not converting all floats.enter image description here

Thank you in advance!

Tried cast the data type in a script after uploading a csv all float columns as all varchars, it uploaded and then I tried to change data types in a script manually. It still gives an error that it is impossible.

jarlh
  • 42,561
  • 8
  • 45
  • 63
  • Are you in a locale which uses comma(,) as decimal separator? – Roger Lindsjö Jun 21 '23 at 11:50
  • That's a single quote (`'`) not a comma (`,`), @RogerLindsjö . – Thom A Jun 21 '23 at 11:52
  • @ThomA Fixed. Thanks – Roger Lindsjö Jun 21 '23 at 11:54
  • Thank you for reply. Why should be a comma? other csv tables are imported correctly. The problem only with this one.. Thank you! – subzerowitch Jun 21 '23 at 12:46
  • it shows the error while importing trough wizard: ✗ Microsoft.SqlServer.Prose.Import.BcpProcessException: Error inserting data into table. ---> System.InvalidOperationException: The given value '0.0' of type String from the data source cannot be converted to type float for Column 5 [new_cases]. ---> System.FormatException: Failed to convert parameter value from a String to a Double. ---> System.FormatException: The input string '0.0' was not in a correct format. at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, ReadOnlySpan`1 value, TypeCode type) – subzerowitch Jun 21 '23 at 13:37

1 Answers1

0

I tried to replicate the issue in my environment. Downloaded the csv file from given link and tried to import the file into azure data studio. I got the same error:

enter image description here

While importing CSV files Azure data studio taking nvarchar(1) data type to the string columns by default. I changed the datatype to nvarchar(50) to the string columns and selected Allow Nulls values to all columns to insert including null data.

enter image description here

After above changes the data imported successfully into database.

enter image description here

While importing the once check the data types according to the data. Imported data table:

enter image description here

Bhavani
  • 1,725
  • 1
  • 3
  • 6
  • thank you!I tried the same in my answer below. Still the error. – subzerowitch Jun 22 '23 at 08:32
  • As mentioned in this [image](https://i.imgur.com/V8g9TI3.png) I just changed the string columns datatype length didn't change another columns datatype. It imported successfully. Share your sample data I will try with that. – Bhavani Jun 22 '23 at 08:52
  • https://drive.google.com/drive/folders/1_ud2G-NT49foL60qU60mKUbfh_C9moSP here are 2 .csv files made up from the file, I separated for convenience. There are also screenshots of steps I took. Thank you @Bhavani – subzerowitch Jun 22 '23 at 10:52
  • Check with [this](https://i.imgur.com/JT3hgya.png). It was able to import csv deaths.csv file – Bhavani Jun 22 '23 at 11:47
  • Some of your data is mixed with characters and digits for that type of data we need to mention them as nvarchar(50) datatype. we don't have any other option. – Bhavani Jun 22 '23 at 11:48
  • Do you mean that cells have floats and then suddenly have Jul.27 ? – subzerowitch Jun 22 '23 at 12:05
  • I appreciate your help and time! Was very glad that someone replied @Bhavani – subzerowitch Jun 22 '23 at 12:06