# CData Sync - CSV Source file questions

**URL:** <https://community.cdata.com/t/cdata-sync-csv-source-file-questions/438>\
**Category:** CData Sync\
**Tags:** question, cdata-sync, csv-connector\
**Created:** [October 6, 2023, 11:59am UTC](https://community.cdata.com/t/cdata-sync-csv-source-file-questions/438 "2023-10-06T11:59:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DougN\_Nouria](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@DougN\_Nouria](https://community.cdata.com/u/DougN_Nouria)\
**Post date:** [October 6, 2023, 11:59am UTC](https://community.cdata.com/t/cdata-sync-csv-source-file-questions/438/1 "2023-10-06T11:59:41Z")

</div>

Hello, couple of CSV source related questions…

1. How do I indicate, for a CSV-based source is, what the primary key column is for each table, so that an upsert can be properly done?
2. Is it possible to move the files to another folder (in the operating system)&nbsp;after Sync has ingested them?&nbsp; We would want to archive the files so they don’t get re-processed the next time.&nbsp; I can do this outside of Sync if necessary, but it would be cleaner if Sync could do this somehow (or call out to a batch file on the OS and run that).
3. In my case, I have many source files with a timestamp, like MYFILE\_XYZ\_20231006.TXT.&nbsp; I would like to use the file Aggregation so that I can just pull them all into the same target table.&nbsp; However when I do that, is there a way to pass along the individual filename being processed, into a column in the target table?

Thank you for any assistance you can provide!

---

<div class="post-metadata">

**Author:** ![Taylor](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@Taylor](https://community.cdata.com/u/Taylor)\
**Post date:** [October 16, 2023, 5:20pm UTC](https://community.cdata.com/t/cdata-sync-csv-source-file-questions/438/2 "2023-10-16T17:20:21Z")

</div>

Hi @DougN_Nouria &nbsp;,

1. You can set&nbsp;the Primary Keys of a source table by modifying the query for the Task. For instance, let’s say I have a source file called DateTest.csv and I want to set "Col1” as the PK. If you edit the task and navigate to the "Query” tab, you can then edit the query syntax like so:

2. CData Sync supports both of those options through [Events](https://cdn.cdata.com/help/ASJ/sync/Events.html). Here you can define executions that run before and/or&nbsp;after a job completes.

3. This requires&nbsp;using the&nbsp;[Load from Folder](https://cdn.cdata.com/help/ASJ/sync/Tasks.html#load-from-folder)&nbsp;job type. It enhances the&nbsp;[Aggregate Files](https://cdn.cdata.com/help/RVJ/ado/RSBCSV_p_AggregateFiles.htm)&nbsp;property by adding additional metadata to the destination table (filename, filemodtime, rownumber) and&nbsp;ensures only new/updated files are processed while skipping files that have already been replicated.

---

<div class="post-metadata">

**Author:** ![DougN\_Nouria](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@DougN\_Nouria](https://community.cdata.com/u/DougN_Nouria)\
**Post date:** [October 16, 2023, 5:22pm UTC](https://community.cdata.com/t/cdata-sync-csv-source-file-questions/438/3 "2023-10-16T17:22:29Z")

</div>

Awesome, thank you so much, I will check this out!
