|
read_csv_001.cpp File modified time Sat Aug 05 17:38:37 2023
0001 #include <tchar.h> 0002 #include <windows.h> 0003 #include <windowsx.h> 0004 0005 #include <ctime> 0006 0007 #include <stdio.h> 0008 #include <stdlib.h> 0009 0010 #include "Print.h" 0011 #include "array_counter.h" 0012 #include "parse.h" 0013 0014 #include "read_csv_001.h" 0015 0016 int csv_once (int *index, int *end_index ) ; 0017 char get_char_001 () ; 0018 int endline ( char bc, char c) ; 0019 int puttheword ( int ii, int jj, char* word ) ; 0020 char* m_concat_c_001 ( char* word , int c ) ; 0021 0022 0023 char* word = NULL; 0024 char* word_c = NULL; 0025 0026 // Add; mode and quotes 0027 // example 0028 int csv_once (int *index, int *end_index ) { 0029 int i; 0030 int ii, jj; 0031 int mode; 0032 int count = 0; 0033 char c, bc; 0034 int word_cnt; 0035 int continued_flg = 0; 0036 0037 mode = 0; 0038 ii=0; jj=0; 0039 0040 for ( i = *index; i< 10 + *index && i < *end_index; i++ ) { 0041 count++; 0042 c = get_char_001 (); 0043 0044 if ( mode == 0 && c == '\,' ) { 0045 ii++; 0046 continued_flg = 1; 0047 } if ( mode == 0 && endline ( bc, c) ) { 0048 word_cnt = array_count (word); 0049 word[ word_cnt - 1 ] = '\0'; 0050 ii++; 0051 jj++; 0052 continued_flg = 1; 0053 } 0054 0055 bc = c; 0056 0057 if ( continued_flg == 1 ) { 0058 puttheword ( ii, jj, (char*) word ); 0059 word = NULL; 0060 continued_flg = 0; 0061 continue; 0062 } 0063 0064 0065 word_c = (char*) m_concat_c_001 ( (char*) word , (int) c ); 0066 aFree(word); 0067 word = word_c; 0068 } 0069 0070 *index += count; 0071 } 0072 0073 char get_char_001 () { 0074 return 0; 0075 } 0076 0077 int endline ( char bc, char c) { 0078 return 0; 0079 } 0080 0081 0082 int puttheword ( int ii, int jj, char* word ) { 0083 return 0; 0084 } 0085 0086 char* m_concat_c_001 ( char* word , int c ) { 0087 static char* dummy = NULL; 0088 char cc; 0089 0090 cc = (char)c; 0091 0092 if ( dummy == NULL ) { 0093 dummy = (char*) malloc ( sizeof(char) * 4 ); 0094 if ( dummy == NULL ) return NULL; 0095 } 0096 dummy[0] = c; 0097 dummy[1] = '\0'; 0098 0099 return m_concat( word, dummy ); 0100 } 0101 0102
|
|
|
|