Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello all of you who reads this question . First, i do not know how to say, but I kinda need to read files which are incoming after some time and new ones are stored in var/incoming/maws/6451 old ones are in var/incoming/maws/archive/6451. File name are "MetMan100090622071011.rep (the last numbers are for time, when file is formed) The file itselfs contains data like(S:6451;D:060622;T:071006;TA:17.8; and so on), but i need only read specific value TA:17.8 wich is for temperature and time in particular order YYY/mm/d and export it to CSV in that order(YYY/mm/d HH:mm:ss;17.8;) file so that it could be imported into mySQL database.
  • Comment on Reading files and importing data to database

Replies are listed 'Best First'.
Re: Reading files and importing data to database
by rovf (Priest) on Jun 22, 2009 at 07:56 UTC

    I think I understand what you want to achieve, but what exactly is your question? I.e. which part of this task do you have problems with? Also (just for curiosity): Is it really necessary that you first export it to CSV, or is it also an option that you directly write it to the database (which would seem more natural to me, unless you need the CSV file for anything else)? Using a CSV file to contain only 1 value seems to be a bit of an overkill...

    -- 
    Ronald Fischer <ynnor@mm.st>
      My question would be can you help me with the code (if it possible all of it) , how to do that stuff.. and yes it would be option to write directly to database but with that is kinda tricky, becouse the table where we suppose to import that value doesn't have a columm with value T as a temperature so it will need to create that to..
        My question would be can you help me with the code (if it possible all of it)

        While you will get for sure help on concrete programming questions, I'm a bit puzzled why you didn't present already part of the code you already have written. May I ask you your background as a programmer? I assume that you already have programming experience in some other programming language (otherwise I don't think someone would have asked you to do such a task), but how is your Perl experience? In case you have never written a Perl program at all, I strongly suggest to spend at least 1-2 days learning the basics of Perl before starting on a real-world problem.

        the table where we suppose to import that value doesn't have a columm with value T as a temperature so it will need to create that to.

        Aside from the fact that, as you can do a SQL insert statement from Perl, you can do equally well do a SQL modify table statement from Perl, do you really want to create a new column every time the program is run???? Usually, the table is created beforehand (which you can conveniently do outside of Perl), so I still don't see the advantage of having a CSV file.

        -- 
        Ronald Fischer <ynnor@mm.st>

        This site is not a program writing service. We will help you if you have specific problems with your existing program, and we will advise you on how to best approach different problems, but we will not write complete programs for you. You have to be(come) a programmer to participate here.

Re: Reading files and importing data to database
by Anonymous Monk on Jun 22, 2009 at 07:58 UTC