Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Programming for software intermingling(?)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
35 replies to this topic

#1 lb2024   Members   -  Reputation: 118

Like
0Likes
Like

Posted 29 May 2014 - 01:12 PM

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.

 

 



Sponsor:

#2 ApochPiQ   Moderators   -  Reputation: 17225

Like
0Likes
Like

Posted 29 May 2014 - 02:01 PM

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.



#3 DiegoSLTS   Members   -  Reputation: 2048

Like
0Likes
Like

Posted 29 May 2014 - 06:28 PM

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.



#4 lb2024   Members   -  Reputation: 118

Like
0Likes
Like

Posted 30 May 2014 - 10:11 AM

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.

#5 ApochPiQ   Moderators   -  Reputation: 17225

Like
1Likes
Like

Posted 30 May 2014 - 10:17 AM

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.



#6 swiftcoder   Senior Moderators   -  Reputation: 12464

Like
1Likes
Like

Posted 30 May 2014 - 04:27 PM


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.


Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#7 ApochPiQ   Moderators   -  Reputation: 17225

Like
0Likes
Like

Posted 30 May 2014 - 05:38 PM

Yeah, fair enough; I just object to the mentality that "oh you want to process data therefore THE ONLY RIGHTEOUS AND HOLY ANSWER IS FOO."



#8 swiftcoder   Senior Moderators   -  Reputation: 12464

Like
0Likes
Like

Posted 30 May 2014 - 05:48 PM

Yeah, fair enough; I just object to the mentality that "oh you want to process data therefore THE ONLY RIGHTEOUS AND HOLY ANSWER IS FOO."

You clearly don't remember writing CGI scripts in ANSI C ;)


Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#9 ApochPiQ   Moderators   -  Reputation: 17225

Like
1Likes
Like

Posted 30 May 2014 - 06:07 PM

Oh yes I do :-P

 

That's kinda my point, really; use what is good for the job, but weigh that against what tools you have immediately available.



#10 lb2024   Members   -  Reputation: 118

Like
0Likes
Like

Posted 30 May 2014 - 07:53 PM

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.

#11 ApochPiQ   Moderators   -  Reputation: 17225

Like
2Likes
Like

Posted 30 May 2014 - 08:00 PM

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.

#12 lb2024   Members   -  Reputation: 118

Like
0Likes
Like

Posted 31 May 2014 - 10:48 PM

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.

#13 swiftcoder   Senior Moderators   -  Reputation: 12464

Like
0Likes
Like

Posted 01 June 2014 - 05:01 AM


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.


Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#14 lb2024   Members   -  Reputation: 118

Like
0Likes
Like

Posted 01 June 2014 - 11:47 AM

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.

#15 swiftcoder   Senior Moderators   -  Reputation: 12464

Like
0Likes
Like

Posted 01 June 2014 - 01:48 PM

I'm more looking for details on the format of the *contents* of the file.

 

Is it text-based? binary? xml? key-value pairs?


Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#16 lb2024   Members   -  Reputation: 118

Like
0Likes
Like

Posted 01 June 2014 - 02:19 PM

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

#17 RobTheBloke   Crossbones+   -  Reputation: 2349

Like
1Likes
Like

Posted 01 June 2014 - 03:13 PM

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:

 

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;

}

 

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. 



#18 lb2024   Members   -  Reputation: 118

Like
0Likes
Like

Posted 01 June 2014 - 06:57 PM

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?

#19 ApochPiQ   Moderators   -  Reputation: 17225

Like
1Likes
Like

Posted 01 June 2014 - 09:33 PM

Why would you write a program that does nothing but run another program? And how does that help you solve your problem?

#20 lb2024   Members   -  Reputation: 118

Like
0Likes
Like

Posted 01 June 2014 - 10:14 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS