pub fn to_file<H: HashTable, P: AsRef<Path>>(
jmap: &JMapInfo<H>,
path: P,
options: &IoOptions,
) -> Result<()>Expand description
Write a JMapInfo to a file
§Arguments
jmap- TheJMapInfoinstance to write to the filepath- The path to the file where the BCSV data should be writtenoptions- Options for endianness and string encoding
§Type
H- The type of hash table used by theJMapInfo, which must implement theHashTabletraitP- A type that can be converted to aPathreference, such as&strorString
§Returns
Ok(()) if the file was successfully written, or an error if the file cannot be created or written to
Examples found in repository?
examples/write_bcsv.rs (line 18)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let lookup_path = Path::new("assets/strings_SMG.txt");
8 let hash_table = smg_hash_table_with_lookup(lookup_path)?;
9
10 let csv_path = Path::new("assets/examples/scenariodata.csv");
11 let jmap = from_csv(hash_table, csv_path, None)?;
12
13 println!("CSV Info");
14 println!("Entries: {}", jmap.len());
15 println!("Fields: {}", jmap.num_fields());
16 println!();
17
18 to_file(&jmap, "test_output.bcsv", &IoOptions::default())?;
19 println!("\nExported to test_output.bcsv");
20
21 Ok(())
22}