file_to_array

From Kolmafia
Revision as of 04:49, 21 December 2020 by Philmasterplus (talk | contribs) (Created page with "<onlyinclude>{{{{{format|Function2}}} |name=file_to_array |function1.return_type={{type|string}} <nowiki>[</nowiki>{{type|int}}<nowiki>]</nowiki> |function1.description=Reads...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Function Syntax

string [int] file_to_arraystring filename )

Reads data from a text file and returns a map of strings containing each line.
  • filename: Path to the text file

The returned value is actually a map of strings, one string for each line. Like file_to_map(), empty lines and those starting with a # are ignored.

Code Samples

Reads a data file into a map of strings.

string [int] lines = file_to_array("mydata.txt");

See Also

file_to_map() | map_to_file()