Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
I'm trying append the csv file in the repository with a service.
My code looks like below.
var params = {
infoTableName : "result",
dataShapeName : "WriteDataShape"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(ds1)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var newRow = new Object();
newRow.ID = ID;
newRow.Name = Name;
//infotable1Object.rows[0] = newRow;
result.AddRow(newRow);
var params2 = {
path: "WriteFile.CSV" /* STRING */,
data: result /* INFOTABLE */,
fileRepository: "SystemRepository" /* THINGNAME */,
withHeader: true /* BOOLEAN */
};
// no return
var result = Resources["CSVParserFunctions"].WriteCSVFile(params2);
Could anyone please tell me why the data in CSV file gets overwritten every time I call this service ?
Solved! Go to Solution.
Hi @Explorerhere29.
The service you are using will always overwrite. Another approach:
Using ReadCSVFile, read in the existing CSV file in the repository as an Infotable as opposed to creating a new table each time as you are doing here:
dataShapeName:STRING):INFOTABLE(ds1)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
Once you're read in the CSV file as an Infotable, you can append rows as you are currently doing in your code.
Regards.
--Sharon
Hi @Explorerhere29.
The service you are using will always overwrite. Another approach:
Using ReadCSVFile, read in the existing CSV file in the repository as an Infotable as opposed to creating a new table each time as you are doing here:
dataShapeName:STRING):INFOTABLE(ds1)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
Once you're read in the CSV file as an Infotable, you can append rows as you are currently doing in your code.
Regards.
--Sharon
For appending rows can I use WriteCSV function or some other ?
Thanks alot !!
This was the solution.