Conference Room SAD


[Thread display] [Reply] [New arrival display] [Word search] [Notes] [管理用]

No. 108
Title Re^2: ファイル読み込み速度
Date : 2016/05/19(Thu) 14:12:10
Name Y. Seimiya
URL
> > SADで10M程度のテーブルファイルを読み込む際、以下のように書いているのですが、読み込みに5分から10分程度かかってしまいます。早く読み込む方法をご存知でしたら教えていただけますと幸いです。
> >
> > While[((v=Read[f,Real])<=>EndOfFile),AppendTo[tbl,v]];
>
> 1. 長いリストに対するAppendToの効率は極めて悪い
> While + AppendTo Table + Breakに置き換える
> Table[With[{v = Read[f, Real]}, If[v === EndOfFile,Break[], v]], {Infinity}]
> 但し、長すぎると SAD Stackがあふれるので、長さが不定なら適当な長さでTableを止めて外部のループでFlatte[*, {1}]かJoinでつなぐ
>
> 2. Whileで繰り返しReadを呼び出すのが効率が悪い
> File Formatが既知であれば、OpenRead時に shell commandを渡して、SAD Listに整形してしまう
> f = OpenRead["!(echo '{'; sed <some-replace-commands> <file>; echo 'Null[]}' )"];
> tbl = Read[f];
> Close[f];


ご回答ありがとうございます。おかげで問題が解決いたしました。

- Related List tree (Click ▼ to display all articles in a thread.)


- Reply Form (Reply to the above using the following.)
Name
E-Mail
Subject
Message
URL
Password (alphanumeric characters within 8)
Subscribe Key (Enter the number of the right image) Post key


- Modify or delete a contributeted article using the following form. -
Do No Password

- WebForum -