• Advertisement
Sign in to follow this  

Programming for software intermingling(?)

This topic is 1331 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello.

 

I'm not necessarily new to programming (in fact I've knew about gamedev for years now), but I'm not the best either.

 

But before going into too much details into me, I am wondering how to make a program open and gather information out of another program and insert data it into another one.

 

To be clear, I work gathering loads of data. I test cable lines and knowing the peak of lines, and distance is important. This data is saved as a ".dat" file and contains important information that is usually repeated throughout the testing process. What I want, is to retrieve certain elements of that file (peak, distance, etc) and create a file that can embed the information into Excel (or excel like workbook).

 

I also want to create a ".txt" file (manually using notepad) and have that imported into Excel (or an excel like workbook).

 

I also want the program to read file names (inside a folder) and check to see if I have all the files needed and if not which ones are missing or which ones are named incorrectly.

 

This is important to me because I'm spending days just compiling different lines but the same information into excel sheets, and if I could just make something that reads the file and insert them automatically that will save me so much time.

 

I don't intend to crack, alter, or do anything malicious to the software I'm reading, but I do want to be able to pull information out and place into another one.

 

I hope you guys can help me so I can save myself the headache of working night and day doing the same monotonous work. Thanks.

 

 

Share this post


Link to post
Share on other sites
Advertisement

Well, the first thing you need to know is what the input data format looks like. The second thing is what you want the output data format to look like.

 

If you can specify the details of both of those, it should be pretty straightforward to write code to do the conversion automatically.

Share this post


Link to post
Share on other sites

It sounds like you need a script. It depends on the platform, but you can write a bash (on unix) or ar batch (on windows) file and do those things. You can check directories and files and then open or close other applications with the input and output needed.

 

Also, you can do those things with other less frustrating and flexible languages like Perl (Practical Extraction and Report Language), but I'm not sure how easy you can open other apps with that program (basically, you're creating a new process, and that is platform dependant).

 

If you wan't to write lines to an opened Excel file... I have no idea if that's possible.

Share this post


Link to post
Share on other sites
I'm not sure how hard PEARL is to learn but will making a script allow me to operate other software and check parameters to make sure its correct before making a pdf and txt for example. And will PEARL allow checking a folder and the data filename one by one and check against a txt file to make sure all is there?

Other options? I appreciate the feedback. In a few days I'll go head first in whatever I need because this data train never stops lol.

Share this post


Link to post
Share on other sites

In my opinion... don't bother learning a whole new language just because it might be 5% more efficient. If you already know how to program, just use what you know. Unless you're exclusively writing code for calculators, your language of choice almost certainly can do file I/O and basic data transformations. Use it.

Share this post


Link to post
Share on other sites


Unless you're exclusively writing code for calculators, your language of choice almost certainly can do file I/O and basic data transformations. Use it.

My only caveat to that would be that if your language of choice happens to be C, C++ or their close relatives, and the file formats your are working with are text-based, then you may find that various other languages (Python, Perl, etc) are drastically simpler to perform text manipulations in.

 

However, if you are only implementing this once, then as ApochPiQ says, no point learning a whole new language.

Share this post


Link to post
Share on other sites
Any good sites or resources to find out how to do what I need in c++(this one? )? What exactly is it called what im doing? (Scripts? ) I'm willing to do the leg work but I'm not quite sure the starting points.

Share this post


Link to post
Share on other sites
This is what you need:

Well, the first thing you need to know is what the input data format looks like. The second thing is what you want the output data format to look like.
 
If you can specify the details of both of those, it should be pretty straightforward to write code to do the conversion automatically.


Specify what the actual job is, and we can help with implementation.

Share this post


Link to post
Share on other sites
What I want is my program to open a file. Once that file is open, I want my program to check the file for: name, limit line, peak value, markers on peak. Once my program verifies that the file is correct it will record those numbers then create a pdf (the software my program will open can do all the above things so my program will just go through checking then using their software to create the pdf)

Now once the file is checked and made into a pdf, if possible, I want this info to populate cells in an excel sheet. This can go on for hundreds to a few thousand times.

Is that enough info? Sorry if my jargon is off.

Share this post


Link to post
Share on other sites


What I want is my program to open a file. Once that file is open, I want my program to check the file for: name, limit line, peak value, markers on peak. Once my program verifies that the file is correct...

Can you show us an example of the actual file? There are a million different ways that a name could be stored in a file, and that affects how you read it back out.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
How would I find that out? Its a very basic file of a frequency wave and a few text saved as a ".dat".

Share this post


Link to post
Share on other sites

How would I find that out? Its a very basic file of a frequency wave and a few text saved as a ".dat".

 

Open it in a HEX editor?  (or text editor if it's a text based file?) Or consult the file format spec? Swiftcoder is right. Effectively you have a data-structure, albeit one that's been serialized to disk. The structure of your data will, to a large extent, influence how relevant or applicable the advice we give will be. This returns the contents of any file as a string:

 

[source]

std::string loadFile(const char* filename)
{

  std::string p;

  std::FILE* fp = std::fopen(filename, "rb");
  if(fp)

  {
    std::fseek(fp, 0, SEEK_END);
    size_t s = std::ftell(fp);
    if(s)  
    {

      std::fseek(fp, 0, SEEK_SET);

      p.resize(s);
      std::fread(&p[0], 1, s, fp);

    }

    std::fclose(fp);
  }

  return p;
}

[/source]

 

Now, you wouldn't actually want to use that. Probably. Maybe. Possibly. Who the hell knows? Take the gamble? Phone a friend? I don't know, nor does anyone else.

 

To use a car analogy:  The above code gives permission for a passenger to open a car door. Swiftcoder is merely asking what your passengers will find beyond that door. Will they find that the car is stationary? Will they find the ground rushing past them at 70mph? Will they find that the car has actually been compressed, in a vice, and that the doors cannot open?

 

How you tackle problems of this sort are 'usually' formulaic. I'm happy to step onto tarmac that isn't moving, less enthusiastic when it's moving at speed (stop first!), and would like to know whether I should keep my mobile on me, just in case someone tries to squish me in a vice. 

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Quite a few people are trying to advise you on good ways to accomplish the task you are talking about, but you seem to be very reluctant about showing exactly -what- you are trying to do.

You might as well be saying, "See I have this play, but I don't know if the script is any good, can anyone tell me?" and not posting any of the play.

Personally my force powers are a bit off these days so I have trouble reading things that aren't around to see. Edited by Satharis

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

The process is indeed very straightforward, aside from maybe emitting PDF documents and interacting with Excel (although both are totally possible).

 

I'm honestly a little confused about your level of comfort with programming, though. If you're actually comfortable in C or C++, and you can spell out the logic and requirements, you're 90% of the way to a working program. The rest is just making API calls.

 

The only reason I can see you having such trouble envisioning how to do this is if you're not really very practiced with programming. This is fine - we all start someplace - but it would be better to be upfront about it so we know how best to help you.

 

 

I think the reason for all the questions is we're seeing your posts and assuming you don't know how to do the basic parts. If that's true, then you need to actually work with the posters asking questions, by either providing the information they're looking for, or explaining why you can't. On the flip side, if you've got the basics handled and really just need help with something more specific (say, PDF emission), then please say so.

 

As it stands, I don't think anyone really knows how to be useful to you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement