Generate CSV - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Generate CSV (/showthread.php?tid=1887) |
Generate CSV - christian.hegland@caverion.com - 04.02.2019 Hi, I've been trying the examples from openrb, regarding CSV file generation locally and over FTP. This seems to work flawlessly. But I would really like to split up the buffer string, so that each object.value goes to each own column. Anybody got a suggestion? Best regards Christian RE: Generate CSV - Erwin van der Zwart - 04.02.2019 Hi, The buffer string is already comma separated so you should have multi column. Did you opened the file as csv comma separeted in excel? RE: Generate CSV - admin - 05.02.2019 Can you provide an example of how resulting CSV should look like, should it look like this? Code: Obj1,Obj2,Obj3 RE: Generate CSV - christian.hegland@caverion.com - 06.02.2019 Hi Guys, Sorry for the delay. Really appreciate your effort to help me out. My csv now looks like this: [ column A address,"name","date","value" 0/6/16,"Heating Active Energy","2019.02.05 23:53:54","4.38843238774139e-40" 0/6/17,"Heating Active Power Total","2019.02.05 23:54:35","2213.32983398438" ] But would like to have "address" in cloumn A, "name" in Column B, "date" in Column C, and "value" in Column D. I use the standard ftp script from openrb examples. Also notice the value from GA 0/6/16, which is raw format. Is it possible to only log decoded values? best regards Christian RE: Generate CSV - admin - 07.02.2019 You need to replace two lines: From: Code: buffer = { '"date","address","name","value"' } Code: buffer = { '"address","name","date","value"' } From: Code: csv = string.format('%q,%q,%q,%q', logdate, knxlib.decodega(row.address), object.name, tostring(data)) Code: csv = string.format('%q,%q,%q,%q', knxlib.decodega(row.address), object.name, logdate, tostring(data)) As for 4.38843238774139e-40 it not a raw format it's scientific notation. This is used for very small floating point numbers which would be too long if displayed in 0.000... format. RE: Generate CSV - christian.hegland@caverion.com - 07.02.2019 (07.02.2019, 07:55)admin Wrote: You need to replace two lines: Thank you very much for you help! I've already done these changes, but the generated csv, still have all data in one column :/ RE: Generate CSV - admin - 07.02.2019 What are using to open CSV? RE: Generate CSV - christian.hegland@caverion.com - 08.02.2019 (07.02.2019, 16:54)admin Wrote: What are using to open CSV?Microsoft Excel 2010 RE: Generate CSV - Daniel - 08.02.2019 Upload your csv here RE: Generate CSV - admin - 08.02.2019 Excel might require semicolon instead of comma. See this for more info: https://stackoverflow.com/questions/10140999/csv-with-comma-or-semicolon You can either change regional settings locally, modify script to use semicolon or use LibreOffice which can open any kind of CSV RE: Generate CSV - Daniel - 08.02.2019 In Excel you have to open empty sheet and then go to DATA and from CSV/text. Then you select your file and you can select separator which is coma by default. Excel will also by default display group as a data so changing to text make sense. In 2010 it might be slightly different I have 365. |