This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Generate CSV
#1
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
Reply
#2
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?
Reply
#3
Can you provide an example of how resulting CSV should look like, should it look like this?
Code:
Obj1,Obj2,Obj3
Val1,Val2,Val3
Reply
#4
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
Reply
#5
You need to replace two lines:

From:
Code:
buffer = { '"date","address","name","value"' }
To:
Code:
buffer = { '"address","name","date","value"' }

From:
Code:
csv = string.format('%q,%q,%q,%q', logdate, knxlib.decodega(row.address), object.name, tostring(data))
To:
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.
Reply
#6
(07.02.2019, 07:55)admin Wrote: You need to replace two lines:

From:
Code:
buffer = { '"date","address","name","value"' }
To:
Code:
buffer = { '"address","name","date","value"' }

From:
Code:
csv = string.format('%q,%q,%q,%q', logdate, knxlib.decodega(row.address), object.name, tostring(data))
To:
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.

Thank you very much for you help! I've already done these changes, but the generated csv, still have all data in one column :/
Reply
#7
What are using to open CSV?
Reply
#8
(07.02.2019, 16:54)admin Wrote: What are using to open CSV?
Microsoft Excel 2010
Reply
#9
Upload your csv here
------------------------------
Ctrl+F5
Reply
#10
Excel might require semicolon instead of comma. See this for more info: https://stackoverflow.com/questions/1014...-semicolon

You can either change regional settings locally, modify script to use semicolon or use LibreOffice which can open any kind of CSV Smile
Reply
#11
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.
------------------------------
Ctrl+F5
Reply


Forum Jump: