Skip to main content

I put in a ticket for Incident IQ because CSV file format was not correct as the file being created is placing one extra comma in the file when as seen when you open it up with notepad. Hoping that they fix this format problem as I have to save the file as file type CSV to fix the Excel downloads all the time!

 

The person working support decided that it was no big deal and closed the ticket on support, but the file format is still not CSV by standards. I wonder how many other people are finding this a problem who use Incident IQ on the Excel data files that they download? I think fixing this problem would eliminate this happening and also would gain more customers confidence in Incident IQ in the future. 

 

 

 

Note: Normal CSV file doesn’t have a comma on the last column value.   

Integration will not work with CSV format like this, unless you change the format. 

I believe the fix to this is C Sharp (C#) in the controller: 

public static void ToCSV(this DataTable dtDataTable, string strFilePath) {

    StreamWriter sw = new StreamWriter(strFilePath, false);

    //headers

    for (int i = 0; i < dtDataTable.Columns.Count; i++) {

        sw.Write(dtDataTable.Columns"i]);

        if (i < dtDataTable.Columns.Count - 1) {

            sw.Write(",");

        }

    }

    sw.Write(sw.NewLine);

    foreach(DataRow dr in dtDataTable.Rows) {

        for (int i = 0; i < dtDataTable.Columns.Count; i++) {

            if (!Convert.IsDBNull(dr i])) {

                string value = drfi].ToString();

                if (value.Contains(',')) {

                    value = String.Format("\"{0}\"", value);

                    sw.Write(value);

                } else {

                    sw.Write(drfi].ToString());

                }

            }

            if (i < dtDataTable.Columns.Count - 1) {

                sw.Write(",");

            }

        }

        sw.Write(sw.NewLine);

    }

    sw.Close();

}

 

It could be that they are using a comma with each row and not reducing the comma delimiter on count using -1???

 

Just trying to help!

 

 


Reply