PC Review


Reply
Thread Tools Rate Thread

Convert a csv to xls prior to import

 
 
kidkosmo
Guest
Posts: n/a
 
      6th Apr 2011
Hi, Gang,

Hoping someone here can help point me in a direction. I get a series
of reports from Webex that I import into an Access database. The
reports export as csv files which are usually easy enough to import;
however, they include report headers on the file I don't want to
import, so I want to import starting at cell B5. As such, I need to
first convert that file to an Excel file since the transfertext method
can't specify cell ranges. Just changing the file extension to xls
doesn't quite work since it still sees the file as unicode text so I
got into each file, do a save as to excel. There's gotta be a better
way.

I've already got VBA to cycle through the directory to import the
files, but does anyone know of a way to cycle through those csv files
and automatically convert them to xls before importing? I've found
plenty of references to converting xls to csv, but not the other way
around.

Below is an excerpt of the file format I get. It's the first four
lines I want to ignore. Any help is appreciated!!

All sessions in Eastern Daylight Time (New York, GMT-04:00)
Session detail for 'Client Basic Care360 Labs & MedsTraining':
*Attention to Duration ratio: Attentiveness based on total duration of
the session.
**Attention to Attendance ratio: Attentiveness based on how long
participant was in the session.
Participant Name Email
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      6th Apr 2011
On Wed, 6 Apr 2011 07:08:53 -0700 (PDT), kidkosmo <(E-Mail Removed)> wrote:

>Hi, Gang,
>
>Hoping someone here can help point me in a direction. I get a series
>of reports from Webex that I import into an Access database. The
>reports export as csv files which are usually easy enough to import;
>however, they include report headers on the file I don't want to
>import, so I want to import starting at cell B5. As such, I need to
>first convert that file to an Excel file since the transfertext method
>can't specify cell ranges. Just changing the file extension to xls
>doesn't quite work since it still sees the file as unicode text so I
>got into each file, do a save as to excel. There's gotta be a better
>way.
>
>I've already got VBA to cycle through the directory to import the
>files, but does anyone know of a way to cycle through those csv files
>and automatically convert them to xls before importing? I've found
>plenty of references to converting xls to csv, but not the other way
>around.
>
>Below is an excerpt of the file format I get. It's the first four
>lines I want to ignore. Any help is appreciated!!
>
>All sessions in Eastern Daylight Time (New York, GMT-04:00)
>Session detail for 'Client Basic Care360 Labs & MedsTraining':
>*Attention to Duration ratio: Attentiveness based on total duration of
>the session.
>**Attention to Attendance ratio: Attentiveness based on how long
>participant was in the session.
>Participant Name Email


Stefan's two step approach is certainly one option; another would be to not
use TransferText at all, but instead use the VBA file-handling code (see the
VBA help for OpenTextFile, TextStream, etc.) to open the file and parse it
yourself.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
Clif McIrvin
Guest
Posts: n/a
 
      6th Apr 2011
"kidkosmo" <(E-Mail Removed)> wrote in message
news:0f304e13-2d40-4e90-ae40-(E-Mail Removed)...
> Hi, Gang,
>
> Hoping someone here can help point me in a direction. I get a series
> of reports from Webex that I import into an Access database. The
> reports export as csv files which are usually easy enough to import;
> however, they include report headers on the file I don't want to
> import, so I want to import starting at cell B5. As such, I need to
> first convert that file to an Excel file since the transfertext method
> can't specify cell ranges. Just changing the file extension to xls
> doesn't quite work since it still sees the file as unicode text so I
> got into each file, do a save as to excel. There's gotta be a better
> way.
>
> I've already got VBA to cycle through the directory to import the
> files, but does anyone know of a way to cycle through those csv files
> and automatically convert them to xls before importing? I've found
> plenty of references to converting xls to csv, but not the other way
> around.
>
> Below is an excerpt of the file format I get. It's the first four
> lines I want to ignore. Any help is appreciated!!
>
> All sessions in Eastern Daylight Time (New York, GMT-04:00)
> Session detail for 'Client Basic Care360 Labs & MedsTraining':
> *Attention to Duration ratio: Attentiveness based on total duration of
> the session.
> **Attention to Attendance ratio: Attentiveness based on how long
> participant was in the session.
> Participant Name Email



A different approach from stefan' or John's suggestions is using the
Windows NT FOR /F command to skip the first lines of the .csv file.

Air code:

Dim strCSVfilename As String ' from your existing code
Dim strCSVnewfilename As String ' can be a temporary file
Dim varLinesToSkip As Variant ' number of lines to skip

Dim strDOScmd As String ' DOS command line string

strCSVfilename = "x"
strCSVnewfilename = "z"
varLinesToSkip = 3

Kill strCSVnewfilename ' delete old output file

strDOScmd = "for /f ""tokens=* skip=" & varLinesToSkip & _
" delims="" %r in (" & strCSVfilename & _
") do echo %r >>" & strCSVnewfilename

Shell strDOScmd

this code will create a copy of the .csv file without the first
varLinesToSkip.

--
Clif McIrvin

(clare reads his mail with moe, nomail feeds the bit bucket :-)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Convert a csv to xls prior to import stefan Microsoft Access 0 6th Apr 2011 04:39 PM
my resume can't be opened how do I convert it prior to sending it JGS Microsoft Word Document Management 3 22nd Feb 2010 09:50 PM
Is there a way to import cookies prior to launching IE6? =?Windows-1252?B?1L/UIE13cw==?= Windows XP Internet Explorer 0 4th Jan 2005 11:17 PM
Help!!! Cannot import pst files from a prior install Ron LaVine at Intellworks.com Microsoft Outlook 1 21st Feb 2004 01:30 PM
Convert to Prior Version S Jackson Microsoft Access Getting Started 1 4th Nov 2003 11:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:42 AM.