Exporting Data to CSV
ABCD allows you to export database records to CSV format for use in Excel or other external systems. This process requires a specialized Print Format (PFT) to structure the columns correctly.
The Logic
Unlike a standard ISO export, a CSV export must:
- Insert commas
,between fields. - Enclose text values in double quotes
"(to handle commas inside the data). - Handle empty fields to maintain column alignment.
1. Creating the PFT
Create a format file (e.g., export_csv.pft) with the following logic:
/* Column 1: Title (Tag 245) - Always present */
if p(v245) then '"',v245,'",' else '"",' fi,
/* Column 2: Author (Tag 100) - Handle quotes inside text */
if p(v100) then '"',replace(v100,'"',"'"),'",' else '"",' fi,
/* Column 3: Year (Tag 260^c) - Last column, no trailing comma */
if p(v260^c) then '"',v260^c,'"' else '""' fi,
/
Handling Quotes
The function replace(v100,'"',"'") is crucial. If your data contains double quotes (e.g., The "Great" Gatsby), it breaks the CSV structure unless you replace them with single quotes.
2. Generating the Header
You need a matching list of column names. Create a file (e.g., header.txt) or simply copy the header line into Excel later.
"Title","Author","Year"
3. Execution
- Go to Utilities > Export.
- Select Output format: Text file.
- Format: Select your
export_csv.pft. - Range: All records (or a search result).
- Click Export.
- Save the resulting file with a
.csvextension.