# CSV specifications: separator and header

**URL:** <https://techcommunity.softwareag.com/t/csv-specifications-separator-and-header/100569>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Linux\
**Created:** [May 16, 2012, 12:50am UTC](https://techcommunity.softwareag.com/t/csv-specifications-separator-and-header/100569 "2012-05-16T00:50:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [May 16, 2012, 12:50am UTC](https://techcommunity.softwareag.com/t/csv-specifications-separator-and-header/100569/1 "2012-05-16T00:50:42Z")

</div>

I’m impressed with how simple it is to read and write CSV files. Natural handles all the messy details, such as headers, delimiters, and quoted strings. All I need to do is provide a list of field names. For example, to read a CSV with values delimited with semi-colons and containing no header line (Natural’s defaults):

```auto
DEFINE DATA LOCAL
1 #CSV
  2 #FIELD1 (A5)
  2 #FIELD2 (N2)
  2 #FIELD3 (A8)
END-DEFINE
DEFINE WORK FILE 1 'c:\spreadsheet.csv' TYPE "CSV"
READ WORK 1 #CSV
  DISPLAY #CSV
END-WORK
END
```

But the only way I can see to change the delimiter and header specifications is via the Configuration Utility. In my client’s environment, changing Natparm files requires a mountain of paperwork, so I was hoping to find WORK subparameters that would allow me to specify these parms dynamically in a batch script. Even a User Exit would be acceptable.

Is there another way to do this?

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [May 16, 2012, 8:10am UTC](https://techcommunity.softwareag.com/t/csv-specifications-separator-and-header/100569/2 "2012-05-16T08:10:29Z")

</div>

Seems like USR2011N is not able to set params for header and separator…  
DC for a workfile would be another helpful parameter.

By the way: I’m impressed, too. It’s even possible to use dynamics. But there are some traps…

```auto
define data local
1 #a10 (A10) init <'A10'>
1 #a (A) dynamic
end-define
define work file 30 '/tmp/test.csv' type 'CSV'
write work file 30 variable #a10 #a
#a := 'testtest'
write work file 30 variable #a10 #a
reset #a
write work file 30 variable #a10 #a
reduce dynamic #a to 0
write work file 30 variable #a10 #a
close work file 30
end
```

output:

```auto
"A10 ";
"A10 ";testtest
"A10 ";" "
"A10 ";
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:01pm UTC](https://techcommunity.softwareag.com/t/csv-specifications-separator-and-header/100569/3 "2021-04-02T15:01:58Z")

</div>


