Solved

Perl CSV Ignore First Line and Export to Access

Posted on 2010-11-19
1
549 Views
Last Modified: 2012-05-10
I am trying to insert the values from a CVS file (with the first row being headers) into an Access Database using a Perl script. The script works, but i need to exclude the first line of the csv file which contains the headers.

Any ideas?
use DBI;

$csvfile="C:/WeatherModel/degrib/bin/Model/Output/gfs_2010111900_72.csv";

$dbh = DBI->connect('dbi:ODBC:driver=Microsoft Access Driver (*.mdb);dbq=c:/weathermodel/weathermodel.mdb', '', '');
$sth = $dbh->prepare( "INSERT INTO GFS_Forecasts VALUES (?,?,?,?,?,?)" );

open CSV, $csvfile;

while(<CSV>) {
  chomp;
  my @fields = split /,/;
  $sth->execute(@fields);
}

close CVS;

Open in new window

0
Comment
Question by:kyle972
1 Comment
 
LVL 11

Accepted Solution

by:
tel2 earned 500 total points
ID: 34177555
Hi kyle,

If I understand you correctly, you should be able to just insert "<CSV>;" between the "open..." and the "while...", like this:

    ...
    open CSV, $csvfile;
    <CSV>;
    while(<CSV>) {
    ...

That should read one line, and do nothing with it.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now