Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Hello,
I'm using the Read CSV Snippet to read a csv file from my repository but this file has some lines at the beginning before starting with the information I want to show as infotable.
Is there any way to skip those likes without modifying the csv?
The csv file looks like this:
# Solar panel simulation inputs 2 of 2
# P9 - T_ambient, P27 - WB_Voc, P26 - Isc, P13 - WB_Panel_fill_factor
Name,P9,P27,P26,P13
1,20,6.1,0.00018,0.6
I want to show the infotable with the info starting on Name,P9… but since the file probably will change from time to time I don’t want to change the format or the content.
Any help would be appreciated.
Thanks
Felix
Hi Felix,
You need to remove that rows on the file itself and rewrite it before parsing it through CSV extension, I do it that way:
var fileRepository = Things["file repository thing"];
var fileContent = fileRepository.LoadText({ path: "path to your file" });
var rows = fileContent.split("\n");
// -- Starting at 7 rows are the good ones.
var newContent = [];
for (var i=7;i<rows.length;i++) {
newContent.push(rows);
}
fileRepository.SaveText({
path: path,
content: newContent.join("\n")
});
Hope it helps,
Carles
Hola Carles,
Thank you for your answer, great idea, I will test it.
Regards
Felix