• Ivy Seo

Read Csv File line by line

Entire code in C# :

public void readAssetsCsvFile()
        {
            int counter = 0;
            string line;
            // Read the file and display it line by line.  
            System.IO.StreamReader file =
                new System.IO.StreamReader(@"/home/ivy/Desktop/postgres_data_test/cvs_files/Assets.csv");
            while ((line = file.ReadLine()) != null)
            {
                System.Console.WriteLine(line);
                insertAssets(line);    // pass the row to ()
                counter++;
            }
            file.Close();
            System.Console.WriteLine("There were {0} lines.", counter);
        }

Recent Posts

See All

Generate unique filename: UUID, Path

A: using UUID let my_uuid = Uuid::new_v4(); let file_created = File::create(my_uuid.to_string()).expect("create file failed");     println!("uuid: {}", my_uuid); //  buffer write let mut file_ge

JSON - write .txt file in Rust

pub fn serialize_writeFile(data : &full_data ) -> Result<bool, modbus::Error> { // 1) takes data  // this function takes the m7_data object and serializes the contents and saves the results to a text

Serialize/Deserialize JSON in Rust

This README has some good examples. To deserialize in Rust: use serde::{Deserialize, Serialize}; use serde_json::Result; #[derive(Serialize, Deserialize)] struct Person {     name: String,     age: u