Posts

Showing posts with the label Csv

Amazon Redshift - COPY From CSV - Single Double Quote In Row - Invalid Quote Formatting For CSV Error

Answer : It's 2017 and I run into the same problem, happy to report there is now a way to get redshift to load csv files with the odd " in the data. The trick is to use the ESCAPE keyword, and also to NOT use the CSV keyword. I don't know why, but having the CSV and ESCAPE keywords together in a copy command resulted in failure with the error message "CSV is not compatible with ESCAPE;" However with no change to the loaded data I was able to successfully load once I removed the CSV keyword from the COPY command. You can also refer to this documentation for help: http://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html#copy-escape Unfortunately, there is no way to fix this. You will need to pre-process the file before loading it into Amazon Redshift. The closest options you have are CSV [ QUOTE [AS] 'quote_character' ] to wrap fields in an alternative quote character, and ESCAPE if the quote character is preceded by...

Bulk Convert DBF To CSV In A Folder ArcGIS 10.1 Using Python

Answer : I have only tested this very briefly (and with a limited variety of data), but this script demonstrates one way this might be accomplished: import arcpy import csv import os import codecs import cStringIO def batch_convert_dbf_to_csv(input_dir, output_dir, rename_func=None): """Converts shapefiles and standalone DBF tables within the input directory input_dir to CSV files within the output directory output_dir. An optional function rename_func may be used to manipulate the output file name.""" # Set workspace to input directory arcpy.env.workspace = input_dir # List shapefiles and standalone DBF tables in workspace tables = list_tables() # Only proceed if there actually exists one or more shapefiles or DBF tables if tables: # Create output directory structure make_output_dir(output_dir) # Loop over shapefiles and DBF tables for table in tables: # Generate ...