importing data with commas in numeric fields into redshift

杀马特。学长 韩版系。学妹 提交于 2019-12-11 01:27:53

问题


I am importing data into redshift using the SQL COPY statement. The data has comma thousands separators in the numeric fields which the COPY statement rejects.

The COPY statement has a number of options to specify field separators, date and time formats and NULL values. However I do not see anything to specify number formatting.

Do I need to preprocess the data before loading or is there a way to get redshift to parse the numbers corerctly?


回答1:


  1. Import the columns as TEXT data type in a temporary table
  2. Insert the temporary table to your target table. Have your SELECT statement for the INSERT replace commas with empty strings, and cast the values to the correct numeric type.


来源:https://stackoverflow.com/questions/39073102/importing-data-with-commas-in-numeric-fields-into-redshift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!