![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
Conversion from a data from line into a tabular form in C/C++Hi all,
I have a text file let say it contains 7 lines. The first line contains the name of 20 cities separated by commas (or spaces). The remaining 6 lines carry corresponding data of the cities let say temprature, Humadity, latitude, longitude etc. Now I want to reorganise this data in a tabular form in another .txt file. I am familiar with fscane, fopen, fclose etc commands but I don't know How to put data in a tabular form. I'll appreciate you prompt help in this regards. GWK Finland |
|
#2
|
||||
|
||||
|
Quote:
Hi Finland. Welcome to GIDForums. What exactly do you mean by tabular format? Do you want your data seperated by tabs? Can you show a sample of what you want the text file to look like? From what I read you want something like 20 lines consisting of: Code:
Is that correct? |
|
#3
|
|||
|
|||
Conversion from a data from line into a tabular form in C/C++Hi dsmith,
Thank you very much for your prompt reply. By tabular I meant writing data in Columns and rows form (in a table) The first row of Table contains parameters names and the 2nd and onward rows carry the coresponding values e.g. ---Table statrs---- __________________________________________________ ___ city_name temp humidity latitude longitude..... __________________________________________________ ___ Helsinki 25 xx xv bv __________________________________________________ ___ Paris 30 .. .. .. __________________________________________________ ___ London 31 .. .. .. __________________________________________________ ___ NY 35 .. .. .. __________________________________________________ ___ .. .. .. .. .. __________________________________________________ ___ .. .. .. .. .. __________________________________________________ ____ Is it possible at all to arrange data in tables in .txt files. Or any other alternative for output files? city_name temp .... Quote:
|
|
#4
|
||||
|
||||
|
Quote:
That is why I asked the question. You can definitely arrange a text file in that format. But I wasn't sure if you wanted something that you could import into excel or something like that. If you truly want a text file that you can print and look to be in tabular format, the fprintf command can be made to align data quite nicely with the format tags and the width specifier. For example: CPP / C++ / C Code:
So if this is what you want to do, I would read in all the entries into a custom structure, then close that file and re-output that structure in your tabular format. HTH, d |
|
#5
|
|||
|
|||
Conversion from a data from line into a tabular form in C/C++Thanks again dsmith!
Actually the output file is suppose to be input file to a prorgram that takes date in columns and rows form. I think that the solution of padding won't work for it. What do u think? (I will try to feed the output file once I get output from the proposed solution) Do you know how to export data to Excel? which could be one possible tabular form. Is it possible to read file name with C. Later on using pointer and fopen that file is opened and then data is arranged/exported to a newly created file. The newly created file name is suppose to be similar to the original file name. The idea is that at the end of day I'll convert all files of a directory into a tabular form. I'll have situation where I will know only the name of the directory but not the individual files' names. Invdividual files would be read and converted and saved to correspoing out put files. Let say a directory has 3 files: sample1.txt; sample2.txt; and sample3.txt. These files names are not know beforehand. Only directory name is known. The goal is to creat corresponding output files named sample1out.txt, sample2out.txt, and sample3out.txt. OR sample1out.xls, sample2out.xls, and sample3out.xls. May I have your email address. Thanks alot again. GWK Finland |
|
#6
|
||||
|
||||
|
Quote:
I see. Do you have any guidelines for what the output format should be? Padding may still work perfectly, if this requires an old column position type where the program is going to look in column 0 for the city name and column 20 for the temparature, etc. This should be your first priority to see exactly what kind of format this needs to be in. Quote:
Quote:
Quote:
You should be getting close to getting Private Messaging privileges here and then you can send me a Private Message. Then if there is a reason for it, I will gladly give you my e-mail address. Cheers, d |
|
#7
|
|||
|
|||
|
Hi dsmith,
Thanks alot for your indepth discussion with me. The prorgram in which i m going to import is limited to our lab only. No body knows about it. I am new to that program as well. I just checked that it needs log files. I will get sample log files and analyze it then i will let u know. I will come to this matter soon. But I got another problem all of sudden. I am use Visual studio .NET. When I debug my code I am getting the following message: 'June10.exe': Loaded 'C:\USERS\Visual Studio Projects\June10\Debug\June10.exe', Symbols loaded. 'June10.exe': Loaded 'C:\WINNT\system32\NTDLL.DLL', Cannot find or open a required DBG file. 'June10.exe': Loaded 'C:\WINNT\system32\KERNEL32.DLL', Cannot find or open a required DBG file. The program '[2388] June10.exe: Native' has exited with code 0 (0x0). ----------------- What can I do in this matter. Regards, GWK Finland |
|
#8
|
|||
|
|||
|
You shouldn't warry about this gwk. This is just a log, that show you which modules you can debug. If the debuger can't load the symbols you just can't debug this modules, but that won't reflect your program. The only problem might be if you wanna debug it. You should find a way to load properly this symbols.
|
|
#9
|
|||
|
|||
Re: Conversion from a data from line into a tabular form in C/C++Quote:
I have the same problem. Lets say that I have a strcture of students with two fields, name and mark given from the keyboard. I vant to export this informations in a excel table file and to be able to reuse this file as imput for a similar program. I did it with binary files with fwrite and fread functions,but I want those informations in a excel table.Is it posible?And I want that badly Can anyone give me a clue?I have no ideea and I need this information 10x. |
|
#10
|
|||
|
|||
Re: Conversion from a data from line into a tabular form in C/C++I gotta go right now, but there was a thread on this a month or so ago. Search this forum a bit on 'excel'.
Excel will take most any delimiter: comma , space, tab ... whatever. There is probably a default to use otherwise you will have to tell Excel what the delimiter is. Pick a delimiter which the file won't otherwise be having in in and generate your file like that. |
Recent GIDBlog
Toyota - 2008 November Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| burning problems PLEASE PLEASE HELP | kelticeire | Computer Hardware Forum | 4 | 01-Dec-2006 16:39 |
| CD burner wont burn!! | robertli55 | Computer Hardware Forum | 1 | 18-Jun-2004 11:53 |
| [CONTEST?]Data Structure Test | dsmith | C Programming Language | 2 | 06-Jun-2004 16:13 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 12:28 |
| CD Buring Failed | skanth2000 | Computer Hardware Forum | 1 | 15-Nov-2003 04:52 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The