コード例 #1
0
    public void keyInit(CSVRow pCsvRow)
    {
        CSVColumnNameIndexer tmpIndex = pCsvRow.GetCSVColumnNameIndexer();
        List <string>        nameLst  = tmpIndex.getColDicLst();

        mKeyNameLst = new List <CsvKeyName>();
        int nCount = nameLst.Count;

        for (int i = 0; i < nCount; i++)
        {
            string     nameVal    = nameLst[i];
            CsvKeyName tmpKeyName = new CsvKeyName();
            tmpKeyName.keyName = nameVal;
            // tmpKeyName.keyVal = pCsvRow.GetString(nameVal);
        }
    }
コード例 #2
0
ファイル: CsvLoader.cs プロジェクト: fuzhoustone/csd
 internal CSVData(string columnNames, char seperator)
 {
     m_columnNameIndexer = new CSVColumnNameIndexer(columnNames, seperator);
 }
コード例 #3
0
ファイル: CsvLoader.cs プロジェクト: fuzhoustone/csd
    public CSVRow(string row, CSVColumnNameIndexer columnNameIndexer, char seperator, Encoding encoding)
    {
        m_columnNameIndexer = columnNameIndexer;

        m_rowDatas = new string[columnNameIndexer.ColumnCount];
        int rowCount = 0;

        int  columnByteCount    = 0;
        bool inColumnBlock      = false;
        bool specialCharOfFront = false;

        var rowBytes = encoding.GetBytes(row);

        for (int i = 0; i < rowBytes.Length; ++i)
        {
            if (rowCount >= m_rowDatas.Length)
            {
                break;
            }

            var oneChar = rowBytes[i];

            //
            if (specialCharOfFront == false && IsSpecialChar(oneChar))
            {
                specialCharOfFront = true;
                continue;
            }

            if (specialCharOfFront)
            {
                if (IsSpecialChar(oneChar) == false)
                {
                    inColumnBlock = !inColumnBlock;
                }
                specialCharOfFront = false;
            }

            //
            if (inColumnBlock)
            {
                g_columnStr[columnByteCount++] = oneChar;
            }
            //
            else
            {
                if (IsSeperatorChar(seperator, oneChar))
                {
                    AddRowData(g_columnStr, ref columnByteCount, ref rowCount, encoding);
                }
                else
                {
                    g_columnStr[columnByteCount++] = oneChar;
                }
            }
        }
        if (rowCount <= m_rowDatas.Length)
        {
            AddRowData(g_columnStr, ref columnByteCount, ref rowCount, encoding);
        }

        //m_rowDatas = Regex.Split(row, seperator + "(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");
        //for (int i = 0; i < m_rowDatas.Length; i++)
        //{
        //    string data = m_rowDatas[i];
        //    if (data.EndsWith("\""))
        //    {
        //        data = data.Remove(data.Length - 1);
        //    }
        //    if (data.StartsWith("\""))
        //    {
        //        data = data.Remove(0, 1);
        //    }
        //    m_rowDatas[i] = Regex.Replace(data, "\"\"", "\"");
        //}
    }