?
Solved

Perl CSV Ignore First Line and Export to Access

Posted on 2010-11-19
1
Medium Priority
?
592 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
tel2 earned 2000 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

762 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