How can we split a csv file into 2 csv files

How can we split one csv file into 2 different csv files?

Example : current data :
[ {
“A”: “12345”,
“B”: “USA”,
“C”: “TestDocumentNumber”,
“Type”: “EmployeeId”,
“D”: “DBI298000020”,
“Value”: “CompanyCode”,
“ID”: “USG_1”
},
{
“A”: “23”,
“B”: “KA”,
“C”: “Testdoc”,
“Type”: “EmployeeId”,
“D”: “DBI298000123”,
“Value”: “CompanyCode”,
“ID”: “USG_3”
}
]

Requirement :
As we are getting the data like the above mentioned way, we want to split this into two files as per the requirement . we want to split this and get the data in 2 different files where, one file to contain A,B,C,D fields and other file to contain type,Value and ID fields

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

As we are getting the data like the above mentioned way, we want to split this into two files as per the requirement . we want to split this and get the data in 2 different files where, one file to contain A,B,C,D fields and other file to contain type,Value and ID fields

Hi @Meghna_Rajeev, you could achieve this using the Edit Fields (Set) node, just make sure you only include only the columns you want to keep. Here’s a quick example workflow:

Hope this helps!

Thankyou MutedJam.

Could you please also help me with another scenario with the splitting a file into two csv according to the values in the header.

Example : current data :
[ {
“A”: “12345”,
“B”: “USA”,
“C”: “TestDocumentNumber”,
“Type”: “EmployeeId”,
“D”: “DBI298000020”,
“Value”: “CompanyCode”,
“ID”: “USG_1”
},
{
“A”: “23”,
“B”: “KA”,
“C”: “Testdoc”,
“Type”: “EmployeeId”,
“D”: “DBI298000123”,
“Value”: “CompanyCode”,
“ID”: “USG_3”
},
{
“A”: “27”,
“B”: “YY”,
“C”: “Testdoc”,
“Type”: “EmployeeId”,
“D”: “DBI298000123”,
“Value”: “CompanyCode”,
“ID”: “USG_3”
},
{
“A”: “98”,
“B”: “AI”,
“C”: “TestDocumentNumber”,
“Type”: “EmployeeId”,
“D”: “DBI298000123”,
“Value”: “CompanyCode”,
“ID”: “USG_3”
},
{
“A”: “21”,
“B”: “SS”,
“C”: “Testdoc”,
“Type”: “EmployeeId”,
“D”: “DBI298000123”,
“Value”: “CompanyCode”,
“ID”: “USG_3”
}
]

Requirement :
As we are getting the data like the above mentioned way, we want to split this into two files as per the requirement . we want to split this and get the data in 2 different files where, one file to contain the objects with C=Testdoc and other file with C= TestDocumentNumber

Result expected
File 1:

[
{
“A”: “23”,
“B”: “KA”,
“C”: “Testdoc”,
“Type”: “EmployeeId”,
“D”: “DBI298000123”,
“Value”: “CompanyCode”,
“ID”: “USG_3”
},
{
“A”: “27”,
“B”: “YY”,
“C”: “Testdoc”,
“Type”: “EmployeeId”,
“D”: “DBI298000123”,
“Value”: “CompanyCode”,
“ID”: “USG_3”
},
{
“A”: “21”,
“B”: “SS”,
“C”: “Testdoc”,
“Type”: “EmployeeId”,
“D”: “DBI298000123”,
“Value”: “CompanyCode”,
“ID”: “USG_3”
}
]

File 2:

[ {
“A”: “12345”,
“B”: “USA”,
“C”: “TestDocumentNumber”,
“Type”: “EmployeeId”,
“D”: “DBI298000020”,
“Value”: “CompanyCode”,
“ID”: “USG_1”
},
{
“A”: “98”,
“B”: “AI”,
“C”: “TestDocumentNumber”,
“Type”: “EmployeeId”,
“D”: “DBI298000123”,
“Value”: “CompanyCode”,
“ID”: “USG_3”
},
]