0

I'm trying to export Two float arrays into a CSV file using IronPython, here's my code

import System
from System import Array

iData = Array.CreateInstance(System.Single, 1024)
qData = Array.CreateInstance(System.Single, 1024)

import csv
with open(r'c:\test.csv', 'w') as fp:
writer = csv.writer(fp, delimiter=',')
for i in range(0, 1024):
    val = repr(iData[i]) + repr(qData[i])
    writer.writerow(val)
print("done")

the above code works fine, but when I open test.csv file I see the following [EXCEL]

enter image description here

[NotePad++]

enter image description here

but what I want to achieve is this (iData[i],qData[i]),

enter image description here

any suggestions please?

6
  • What does Excel think is the delimiter? Commented Jan 30, 2015 at 10:46
  • @LutzHorn, If I'm not wrong. Excel recognizes CSV files with delimiter (,) Commented Jan 30, 2015 at 10:48
  • Please include the exact content of test.csv. Commented Jan 30, 2015 at 10:50
  • The picture shown above is what I see, I had to crop due to higher number of rows(i.e 1024) Commented Jan 30, 2015 at 10:52
  • Please open test.csv in a plain text editor like Notepad++ and add the content (some lines are enough) to your question. Commented Jan 30, 2015 at 10:52

1 Answer 1

1

Try this:

for i in range(0, 1024):
    writer.writerow([iData[i], qData[i]])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.