[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help with reading structure from file
- Subject: Re: Help with reading structure from file
- From: Reimar Bauer <r.bauer(at)fz-juelich.de>
- Date: Sun, 18 Feb 2001 23:04:53 +0100
- Newsgroups: comp.lang.idl-pvwave
- Organization: Forschungszentrum Juelich GmbH
- References: <95q2fs$m1c$1@news.wrc.xerox.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:23572
Surendar Jeyadev wrote:
>
> In the loosing battle with the Excel users, the latest direct hit was reading
> in a file that contained strings and numeric data in each line. Having given
> up (and as the only hold out against Excel!), I need HEEELLLPPP.
>
> This is the simplified problem. I am trying to read data in the following
> format:
>
> 001a 312.194 76.922 296.301 21.462 0.453 289.515 0.957
> 001b 363.748 106.090 506.188 19.430 0.528 347.252 1.176
> 001c 398.248 138.541 724.470 17.152 0.578 383.534 1.701
> 002a 294.593 28.525 248.744 8.532 0.428 290.497 1.268
> 002b 353.415 46.290 449.015 7.974 0.513 349.565 2.011
> 002c 401.279 80.260 661.701 3.341 0.582 395.403 4.529
> ....
> ....
>
Dear Surendar,
this is my solution of this problem.
You will need additional:
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_html/dbase/download/fileline.tar.gz
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_html/dbase/download/n_separator.tar.gz
Please have a look for further routines and licensing at
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.html
FUNCTION read_excel
n_lines=fileline('excel.txt')
txt=STRARR(n_lines)
OPENR,lun,'excel.txt' ,/GET_LUN
READF,lun,txt
FREE_LUN,lun
txt=STRCOMPRESS(txt)
sep=' '
n_sep=(n_separator(txt[1],sep))[0]
pos_sep=STRPOS(txt[1],sep)
asc=STRMID(txt,0,pos_sep)
txt=STRMID(txt,pos_sep+1,10000)
data=FLTARR(n_sep,n_lines)
READS, txt, data
RETURN,{asc:asc,data:data}
END
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
=============================================
a IDL library at ForschungsZentrum Jülich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.html
http://www.fz-juelich.de/zb/text/publikation/juel3786.html