c - How to read data from file and clean and store to a file -
Good day all.
I have a file that contains data which is shown below, in this it records for every 30 seconds for a period of 30 days. I want to do the following on the data.
2010-03-03 16:00:31; 66.89; 24.0; 14.89; 0.08; 2010-03-03 16:00:35; 66.15; 24.1; 14.85; 0.08; 2010-03-03 16: 00:38; 67.10; 24.2; 14.81; 0.08; 2010-03-03 16:00:42; 66.36; 24.3; 14.78; 0.08; 2010-03-03 16: 00:46; 65.83; 24.4; 14.75; 0.09; . . . 2010-03-03 17:00:31; 62.78; 25.2; 13.96; 0.12; 2010-03-03 17:00:35; 63.94; 25.3; 13.92; 0.11; 2010-03-03 17:00:39; 61.94; 25.3; 13.89; 0.11; 2010-03-03 17:00:43; 60.99; 25.4; 13.88; 0.12; 2010-03-03 17:00:46; 62.67; 25.4; 13.89; 0.13; 2010-03-03 17:00:50; 62.57; 25.3; 13.91; 0.13; 2010-03-03 17:00:54; 61.51; 25.3; 13.91; 0.14; . . . 2010-03-03 18:00:29; 66.04; 20.7; 13.63; 0.56; 2010-03-03 18:00:33; 66.04; 20.7; 13.63; 0.56; 2010-03-03 18:37; 65.52; 20.7; 13.59; 0.56; 2010-03-03 18:00:40; 64.46; 20.7; 13.56; 0.56; 2010-03-03 18:00:44; 64.88; 20.8; 13.56; 0.56; . . .
- Read all the lines in the file that starts with the first line. 2. For every hour, I only number of figures and records in the second column that give birth to this amount.
3. Then print a file on the following notifications:
i zodiac (1 hour), the number of records that give birth to this yoga; Zodiac (2 hours), num_records; Amount (3 hours), num_records; ...;
This is an example of the example that I want to print in the file described above;
03 \ 03 \ 2010, 15,093.47; 379; 16,025.46; 380; 14,800.58; 379; 14,605.34; 380; 21754.27379; ... 82279.12,18 943,37 04 \ 03 \ 2010; 6842.051; 379; 7137.491; 380; 7215.16; 380; 7159.189; 379; 6594.672; 380; ...; 34 9 48,56,1898; 1841 05 \ 03 \ 2010; 9938.37; 379; 9670.438; 380; 8232.032; 380; 9198.899; 379; 7083.687; 380; ... 44123.426,1898; 23.25
I started with this code
int file_readline (char * file_in, char * outfile), four * string) {FILE * Fd = NULL; FILE * fo = NULL char * date, * tmp, * time; Double zodiac = 0; Double meaning = 0; Strline = calloc (MAX_BUFFER_SIZE, sizeof (strline)); If (strline == faucet) {printf ("error callout string ................."); Exhaust (EXIT_FAILURE); } File_in = calloc (strlen (strline) + strlen (file_in)), sizeof (file_in)); If (file_in == NULL) {printf ("error callout string ................."); Exhaust (EXIT_FAILURE); } Fd = fopen (file_in, "r"); Int i = 0; Int j = 0; While ((fgets (strlines, buffies, FDs) gt; 0 & amp; amp;; feof (fd)) {date = strtok (strline, ""); Time = strotok (NULL, ""); Tmp = strtok (NULL, ";"); If (i == 3) {// only get the third value sum + = strode (tmp, null); ++ i; // How to not proceed from here
I will make it by contacting each row Parsing an array and then through the array and calculate yourself because it seems that you are doing. It appears that your data is consistent in the file format, so it can also be beneficial to store array cells in special variables, and then casting them is probably the easiest way to float them for math.
Comments
Post a Comment