Exemple #1
0
        private static List <string> TranscribeAndModifyFile(StreamWriter writer, TextReader reader, List <string> fields, bool first, int currentFileCount)
        {
            var fileReader = new DsvFileReader(reader, SEPARATOR);

            if (first)
            {
                fields = fileReader.FieldNames;
                for (int i = 0; i < fields.Count; ++i)
                {
                    if (i > 0)
                    {
                        writer.Write(SEPARATOR);
                    }
                    writer.WriteDsvField(fileReader.FieldNames[i], SEPARATOR);
                }
                writer.WriteLine();
            }

            Debug.Assert(Equals(fileReader.NumberOfFields, fields.Count));
            for (int i = 0; i < fields.Count; ++i)
            {
                Debug.Assert(Equals(fileReader.FieldNames[i], fields[i]));
            }

            while (fileReader.ReadLine() != null)
            {
                for (int i = 0; i < fields.Count; ++i)
                {
                    string modifiedField = fileReader.GetFieldByIndex(i);
                    switch (fileReader.FieldNames[i])
                    {
                    case FILE_NAME:
                        modifiedField = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(modifiedField)) + MS_FILE_TYPE;
                        break;

                    case TRANSITION_GROUP:
                        modifiedField = modifiedField + currentFileCount;
                        break;

                    case RUN_ID:
                        modifiedField = currentFileCount.ToString(CultureInfo.CurrentCulture);
                        break;
                    }
                    if (i > 0)
                    {
                        writer.Write(SEPARATOR);
                    }
                    writer.WriteDsvField(modifiedField, SEPARATOR);
                }
                writer.WriteLine();
            }
            return(fields);
        }
Exemple #2
0
        private static List<string> TranscribeAndModifyFile(StreamWriter writer, TextReader reader, List<string> fields, bool first, int currentFileCount)
        {
            var fileReader = new DsvFileReader(reader, SEPARATOR);
            if (first)
            {
                fields = fileReader.FieldNames;
                for (int i = 0; i < fields.Count; ++i)
                {
                    if (i > 0)
                        writer.Write(SEPARATOR);
                    writer.WriteDsvField(fileReader.FieldNames[i], SEPARATOR);
                }
                writer.WriteLine();
            }

            Debug.Assert(Equals(fileReader.NumberOfFields, fields.Count));
            for (int i = 0; i < fields.Count; ++i)
            {
                Debug.Assert(Equals(fileReader.FieldNames[i], fields[i]));
            }

            while (fileReader.ReadLine() != null)
            {
                for (int i = 0; i < fields.Count; ++i)
                {
                    string modifiedField = fileReader.GetFieldByIndex(i);
                    switch (fileReader.FieldNames[i])
                    {
                        case FILE_NAME:
                            modifiedField = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(modifiedField)) + MS_FILE_TYPE;
                            break;
                        case TRANSITION_GROUP:
                            modifiedField = modifiedField + currentFileCount;
                            break;
                        case RUN_ID:
                            modifiedField = currentFileCount.ToString(CultureInfo.CurrentCulture);
                            break;
                    }
                    if (i > 0)
                        writer.Write(SEPARATOR);
                    writer.WriteDsvField(modifiedField, SEPARATOR);
                }
                writer.WriteLine();
            }
            return fields;
        }