如何从Excel文件读取输出到Fortran? [英] How to read output from Excel file into Fortran?
问题描述
我有一个excel表,其中列出了以下列表:
I have an excel sheet with the following columns for a stock chart:
- 打开
- 高
- 低
- 关闭
- 日平均值
- Open
- High
- Low
- Close
- Day Average
我如何使用Fortran从excel文件中只提取Day Average?
How do i use Fortran to pull only the "Day Average" from the excel file?
我是Fortran的新手并没有找到可以帮助的任何东西,除了下面的链接,但我很难理解,因为我正在寻找与链接显示的不同的东西:
I am new to Fortran and haven't been able to find anything that could help except for the link below but its pretty difficult for me to grasp since i am looking for something different than what the link is showing me:
http://en.wikibooks.org/wiki/Fortran/Fortran_simple_input_and_output
推荐答案
不,与其他答案相反,CSV不是最简单的文件。转到文件/另存为/其他格式并保存为格式化文本(空格分隔)。根据您的区域设置,您将作为小数点使用逗号或全停,因此您必须(使用外部编辑器进行简单的搜索/替换)或编写一个逐字符的fortran子例程,并用一个逗号替换每个逗号。
No, contrary to the other answers CSV is not the easiest file to read. Go to File/Save as/Other Formats and save it as Formatted text (space delimited). Depending on your locale, you will either have a comma or a full stop as a decimal point, so you'll have to (either use an external editor to do a simple search/replace) or write a fortran subroutine that goes character by character, and replaces every comma with a full stop.
之后很容易,没有;
要解析,所以你只是
After that it's easy, no ;
's to parse, so you just
program FreeFormat
real(4), dimension(5) :: open, high, low, close, dayaverage
real(4) :: average
open(unit=1, file='filename.prn', status='old')
do i=1,5
read(1,*)open(i), high(i), low(i), close(i), dayaverage(i)
enddo
average = sum(dayaverage)/5
write(*,'("Average is",f5.2)')average
end program FreeFormat
你得到点...
这里有几个链接可以让你开始(Excel / Fortran DLL相关)...
Here are a few links to get you started (Excel/Fortran DLL related) ...
在excel / fortran dll连接中的文件位置的麻烦
Fortran DLL& MS Excel
这篇关于如何从Excel文件读取输出到Fortran?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!