Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Output to an Excel File

bobae
Beginner
1,524 Views
I compiled a .exe file and it outputs a huge amount of data. How do I make it output to an Excel file or at least put it into columns that I can copy and paste? Thank you!
0 Kudos
8 Replies
Peter
Beginner
1,524 Views
[cpp]program example
real(8), dimension(5):: a,b
 data a/1.0,2.0,3.0,4.0,5.0/,b/6.0,7.0,8.0,9.0,10.0/
 open(unit=5,file='ab.txt', status='unknown')
write(5,6) a,b
6 format(5f5.1,/5f5.1)
end [/cpp]
the output in a text file (ab.txt) looks like this

1.0 2.0 3.0 4.0 5.0
6.0 7.0 8.0 9.0 10.0

the key here is having good knowledge in 'open' and 'format' statements !
HTH


0 Kudos
jimdempseyatthecove
Honored Contributor III
1,524 Views
Quoting - bobae
I compiled a .exe file and it outputs a huge amount of data. How do I make it output to an Excel file or at least put it into columns that I can copy and paste? Thank you!

I use a formatted write with fixed length fields. Use .TXT as file type. Excel will prompt you as to if the file is to be comma delimited or fixed. It does a good job as long as you do not have more that 65,000 lines. Once read in, Save As to Excel Workbook format. With formatted write you can write a rather large number of columns. If you get unwanted line break look at using the RECL specifier in the OPEN.

What is your definition of "huge amount of data"?

Jim Dempsey
0 Kudos
DavidWhite
Valued Contributor II
1,524 Views
Can also add CHAR(9) between each numerical value (add "A" format descriptor to the format statement). The file then is a tab-delimited text file, which Excels import wizard will recognize an immediately parse the data into cells.
0 Kudos
bmchenry
New Contributor II
1,524 Views
I'd suggest you trythe following:
1) output to a file with suffix CSV (Comma delimited)
2)insert a comma between variables in your output format statements.
then Excel or other database programs can easily import the data.

0 Kudos
yourmohsin
Beginner
1,524 Views

I use the following simple formated output statements to get my data out for use in MATLAB. Matlab automatically detect the format and load it without any problem and I guess same would be with excel. Itwrites data in rows and my output is normallyabout 1000 rows of NLX data points (columns)

OPEN(101, FILE='Output_Sc.dat')! open output file to write Sc

WRITE
(101,5)(Sc(IP), IP=1,NLX)! write Sc in file

5 FORMAT (1701E10.2, T1)!1701(=NLX) is number of data points/colums


I hope may be helpful to you.
0 Kudos
wolfgang_knott
Beginner
1,524 Views
Hello!

If you do not like these intermediate files you may want to have a look at the AUTODICE example (part of older versions of the compiler).

Wolfgang

0 Kudos
Steven_L_Intel1
Employee
1,524 Views
AUTODICE is part of the current product samples.
0 Kudos
joerg_kuthe
Novice
1,524 Views
Quoting - bobae
I compiled a .exe file and it outputs a huge amount of data. How do I make it output to an Excel file or at least put it into columns that I can copy and paste? Thank you!
I hope that I am allowed to point you to a library I once developed for that purpose:
qtXLS
qtXLS uses Excel's ODBC driver (comes with Excel) to read from and to write to Excel files (.xls) directly. Here is more information:
http://www.qtsoftware.de/vertrieb/db/qtxls_e.htm

Regards,
Joerg Kuthe
www.qtsoftware.de
0 Kudos
Reply