Jump to content
  • Advertisement

lb2024

Member
  • Content Count

    19
  • Joined

  • Last visited

Community Reputation

118 Neutral

About lb2024

  • Rank
    Member
  1. lb2024

    Searching txt files

    Just for clairfication I'm using c++ so C looks a bit different to me but I'm sure I can figure it out.       Clarify this statement.  You say none are going to be integers, yet your example text contains only integers.  When it comes to string parsing, the details are essential.   Everything in my txt right now are going to be used as strings. Even though it looks like a number, I am only worried about passing it as strings of txt for now. I'll soon be searching txt for numerical values and sorting them for other purposes but right now I'm going step by step trying to get string positions and minuplation.     Where I'm at now is a bit confusing. For example. I'm unsure how to get to the line under the "cbl" and to stop once it gets to another remote number. if (mystring.find ("r=") != string::npos){ rString_pos = mystring.npos + 2; rname = mystring.substr(rString_pos+1, 4); cout <<rname<<endl; } The above finds the string "r=" and moves the npos to the character afterwards then I put the remaining line into rname.   But I can't do the same for cbl. Even the above seems wrong or around-the-way (but it works). I'm thinking of using a while loop but i'm unsure how to write the correct loop with the right paramerters to look for. I tried getline() but that doesn't work because I don't know how to get the string from the line into my string and to continue until it reaches another keyword.
  2. lb2024

    Searching txt files

    Oh thanks a bunch guys. I will research and try my best to create.
  3. lb2024

    Searching txt files

    Thanks for the help, I will research the getline() function. That will most definitly help gathering information for each line.   But is there a way to tell the program to begin after "=" or after finding the desired keyword? Like how to make the program to begin inputting strings after a desired keyword or the next line?
  4. I'm currently learning fstream and I am trying to search a txt file I created for certain strings.   Once I find a string I want to start copying the strings directly under them until I find another string to begin the copying directly under them. Except for my first string I want to copy after the "=" sign then stop after a new line.   For example the txt will look something like this:   R = 1-1 cbl 12 14 16 18   R = 2-1 cbl 11 13 15 17   where R equals the remote number. Cbl means the cables and under "cbl" is the cable numbers (none are going to be integers all are strings).   But I want the out put to be in the format   1-1 12 1-1 14 1-1 16 1-1 18   2-1 11 2-1 13 2-1 15 2-1 17   The reason I am creating this searching and outputting program because once it is in my final format, I plan on inputting them into excel to be placed into a database.   I can open the file but I have no idea how to search word for word and then tell the program to copy next to key words then continue until another keyword.   Help?
  5. Im intermediate. Might be a small curve but I feel confident in a month I could figure it out. Plus you guys been so helpful once I start coding I'll ask for help if I get stuck somewhere. Thanks for the help for real.
  6. But to recheck before I cry triumph, let me gather if I got my logic down right. For me to check a folder and it's content, I will need to learn about "api's" (ie. I have a folder with data and a txt file in which shows what should be in the folder I use some type of reader to crosscheck txt file and filenames in folder) For me to check the values of the contents of my data file, I load the data file into possibly scanf() and search for specific strings and record my values. I then will print out the values in a txt format for use later. I still haven't figured out how to input it into excel automatically, but I'm assuming the "api's" will have something to do with it. Am I on the right track?
  7. Thanks so much guys!!! It's easily read through notepad, so I'm getting the feeling this won't be too hard. So, since I know it's plain-text format, what do I need to do next? I assume what I'm reading are variables but I need to know how to check the values since they will change depending on the file. Here is what it reads like in the notepad:   **Note if I'm doing anything wrong looking at this file through a Hex editor or posting this let me know. I don't want to be doing anything illegal or unethical. I'm just trying to create something to read these and determine if it is good or needs to be changed.   *edit deleted code. (nothing was too important)
  8. And what is the best method of reading .dat files and having my code understand which portions to change if wrong and which ones to record? Since another software im using generated the .dat and I'll be accessing it through my code.
  9. I would consider myself intermediate in the strictest terms. I've never used c++ to control other software so that is the most difficult portion I see. As of all this back and forth, 'Api's' was the word I apparently was looking for lol. Learning the correct Api's will be my focus moving forward. Any good resources for Api's through c or c++?
  10. I apologize if I seem vauge. Im not sure what else to say though. In my imagination it seems straightforward. I want to make a program to follow a script of checks and balances to do work for me. A flow chart will be something on the order of: Open txt file open folder check folder contents against txt file record successful or error open filename check measurement check limit Record value create pdf close file Insert value into excel Rinse and repeat At this point I feel like I just need to start programming away and ask technical questions for portions I am unsure about. I appreciate all the help from you guys. I'll try and whip something up and ask for technical questions from now on.
  11. I want to do it because of the mundane practice of going through thousands of files checking the same thing over and over and then inputting slightly different values all day. If I can create a program that can do it for me it will free up my time to pursue more worthwhile things maybe even more money for me.
  12. What would I need to allow my program to open another program and run said script to automatically :check/change value, record it, make pdf...etc?
  13. How would I find that out? Its a very basic file of a frequency wave and a few text saved as a ".dat".
  14. Site id_cable_rl_lb Basically all the files should have that similar file name. What I plan is creating a txt file for the cross check. So if something is missing my program will notice it and make a file stating whats missing. I feel the hardest part will be using my program to open the software and go through a script where it will check the parameters I need. If the parameter is off I would like it to change it to the correct parameter. Once everything about the data is correct it will record the info then use the software to create a pdf. Afterwards it would populate an excel sheet for me. I know c and c++. I just need to know the libs for strings, and opening other files and reading and manipulating them. Then I believe with a few examples I could whip something up. Once again thanks guys I really appreciate the feed back.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!