Skip to main content

## Solutions to Common Problems

Here are some of the common problems that you may experience when dealing with CSV data, and brief suggestions as to how CSVfix can help you with them:

"The fields in the data are in the wrong order"

Reorder them using the order command.

"The records in the data are in the wrong order"

Sort them using the sort command. Remove duplicates with the unique command.

"Some fields are missing from my data"

If you simply need to add empty fields to keep your application happy, use the pad command. If you need to enrich your data with values from another file, use the join command. If you need to add a fixed string to the data, use the put command.

"My CSV data isn't comma-separated!"

Use the -sep and -rsep flags to tell CSVfix what separator to use.

"I need to read tab-separated data"

Use the read_dsv command with the -s '\t' flag to convert tab-separated data to CSV.

"I need to convert XML to CSV"

The from_xml command probably does what you need.

"I need to perform calculations on some of the fields in my CSV data"

The eval command provides arithmetic and other functions you can apply to your CSV data.

"I need to extract data from the middle of a field"

Use the split_fixed and split_char commands to break fields up into sub fields. If you need to build a field from values in other fields, use the merge command.

"I need to remove some lines from a CSV file before processing it further"

The find and remove commands allow you to filter your CSV files using regular expressions, value ranges and field lengths. You can also create exclusion lists and use the join command with the -inv flag to exclude selected rows.

"I need to merge the data from two CSV files"

Use the order command to get the fields in the same order, and then the unique command to merge them, discarding duplicates.

"I want to add record numbers to my CSV data"

The sequence command provides flexible record numbering.

"I want to split my data into different files"

The file_split command can split CSV data streams depending on field values.

"My data is full of duplicate values"

Remove duplicates using the unique command.

"The data I get given is always full of invalid values"

Validate your data using the validate command. Remove bad values with the remove command.

"I need to convert CSV data into XML"

The to_xml command does exactly this.

"I need to convert CSV data to this weird format"

Use write_fixed, write_dsv and the printf and template commands to format your output.

"I want to extract data from a SQL database as CSV"

In the Windows version of CSVfix, the odbc_get command allows you to extract data from SQL databases.

"I need to import data into a database, but the data is in a weird format"

Use CSVfix to convert the data to CSV using the read_fixed, read_dsv, and/ot read_multi commands, and then convert the CSV to SQL INSERT statements using sql_insert.

"I need special date formatting"

Use the date_format and date_iso comnands to read and re-format dates.

Created with the Personal Edition of HelpNDoc: Full-featured Documentation generator

####