#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    11
    Rep Power
    0

    CSV file column formatting using Perl


    Hi all,

    I have been working perl from a good time and now I have come across one problem.
    I have to read a CSV file and get the data and for few conditions I have to read the 2nd column data which has the time and write it into a text file.

    The data format seems something like "21:09.3" when open with excel file to see the value and prints the same way in my output file.
    Now when I open it with wordpad it shows the same value as "18:21:09.32". I can directly format the column in excel but that has to be done through the perl script itself. So please provide a quick answer soon.

    Help is always appreciated. Thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2009
    Posts
    1,932
    Rep Power
    1225
    Last edited by FishMonger; May 6th, 2013 at 11:33 AM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    11
    Rep Power
    0

    Question


    Originally Posted by FishMonger
    I saw your links well it was good to find many examples related to excel files.

    I actually have to modify the time data of 2nd column in my csv file. How to format cells of an excel file using perl?
    It is to modify the previously present data to the following format- hh:mm:ss.000.
    Please help me soon!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2009
    Posts
    1,932
    Rep Power
    1225
    How to format cells of an excel file using perl?
    Without using the suggested module to create an actual excel file?

    If that's the case, then format your timestamp as desired and use proper quoting so that when you import the csv fiel into excel, it is seen as a string and not a timestamp.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    11
    Rep Power
    0
    Originally Posted by FishMonger
    Without using the suggested module to create an actual excel file?

    If that's the case, then format your timestamp as desired and use proper quoting so that when you import the csv fiel into excel, it is seen as a string and not a timestamp.
    Good news is that, when I am reading the file, each line by line it provides me the exact time and have no issues taking these values into the output file. Thanks for all the help.

IMN logo majestic logo threadwatch logo seochat tools logo