473,322 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

save a flat export data file as an excel file

Hi all,

I have a question for you.

I have a .csv file which has many lines of data.
Each line has many data fields which are delimited by ",".
Now I need to extract part of data from this file but save it as an excel
file.

The data in this excel file will be imported into an Access database. The
reason I have to save it into an excel file is Access program only accept
excel data file, but not flat text file.

Can you tell me how to save extracted data into an excel file?

Thanks.
--
Betty
Jul 17 '08 #1
3 7109
Why go to the trouble of converting CSV to Excel and then Excel to Access????

Why not just use ASP to go directly from CSV to Access???

<%
Set csvconn = Server.CreateObject("ADODB.Connection")
csvconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\path\to\DIRECTORY\only\;" & _
"Extended Properties=""text;HDR=Yes;FMT=Delimited"""

Set dbconn = Server.CreateObject("ADODB.Connection")
dbconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\path\to\yourAccessDatabase.mdb;"

SQL = "SELECT * FROM nameOfFile.csv"
Set inRS = csvconn.Execute( SQL )

Set outRS = Server.CreateObject("ADODB.Recordset")
outRS.Open "TableName", dbconn, adOpenStatic, adLockPessimistic

Do Until inRS.EOF
outRS.AddNew
outRS("field1") = inRS("fieldA")
outRS("field2") = inRS("fieldB")
... etc ...
outRS.Update
inRS.MoveNext
Loop
outRS.Close
inRS.Close
dbConn.Close
csvConn.Close
%>

THere are actually some even more efficient ways to do this, but without
know more of your details I'm hesitant to choose one. The above is simple
minded enough it should work so long as your CSV file doesn't have any quirks.
Jul 17 '08 #2
Hi Betty,

From your description, you have an existing CSV file and you want to
extract some part of the CSV file out and export them into excel file,
correct?

Are you wantting to do it programmtically or just want to do such an
transformation and not necessary to use code? Based on my experience,

#SQL Server 2005 ¨C Integration Services
http://technet.microsoft.com/en-us/s.../bb671392.aspx

#How to import an Excel file into SQL Server 2005 using Integration Services
http://www.builderau.com.au/program/...t-an-Excel-fil
e-into-SQL-Server-2005-using-Integration-Services/0,339028455,339285948,00.h
tm

http://www.mssqltips.com/tip.asp?tip=1202

If this need to be done programmtically, a common approach is read the csv
file via OLD db provider(jet engine) and access the data like a database
table. However, I think it maybe a bit hard to export it exactly as excel
format, btw, excel can directly convert csv format, will it work for your
case.

#How To Open Delimited Text Files Using the Jet Provider's Text IIsam
http://support.microsoft.com/default...microsoft.com:
80/support/kb/articles/Q262/5/37.ASP&NoWebContent=1&NoWebContent=1

#Using OleDb to import text files (tab, csv, custom)
http://www.codeproject.com/KB/cs/UsingJetForImport.aspx

Also, are you going to do this converting in ASP web page? If not, for
normal desktop applicatin, we can use excel automation object model to
create excel worksheet:

http://support.microsoft.com/kb/302096

http://support.microsoft.com/kb/302094

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?YzY3NjIyOA==?= <be***@newsgroup.nospam>
Subject: save a flat export data file as an excel file
Date: Wed, 16 Jul 2008 20:24:01 -0700
>
Hi all,

I have a question for you.

I have a .csv file which has many lines of data.
Each line has many data fields which are delimited by ",".
Now I need to extract part of data from this file but save it as an excel
file.

The data in this excel file will be imported into an Access database. The
reason I have to save it into an excel file is Access program only accept
excel data file, but not flat text file.

Can you tell me how to save extracted data into an excel file?

Thanks.
--
Betty
Jul 17 '08 #3

"Old Pedant" <Ol*******@discussions.microsoft.comwrote in message
news:90**********************************@microsof t.com...
Why go to the trouble of converting CSV to Excel and then Excel to
Access????

Why not just use ASP to go directly from CSV to Access???

<%
Set csvconn = Server.CreateObject("ADODB.Connection")
csvconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\path\to\DIRECTORY\only\;" & _
"Extended Properties=""text;HDR=Yes;FMT=Delimited"""

Set dbconn = Server.CreateObject("ADODB.Connection")
dbconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\path\to\yourAccessDatabase.mdb;"

SQL = "SELECT * FROM nameOfFile.csv"
Set inRS = csvconn.Execute( SQL )

Set outRS = Server.CreateObject("ADODB.Recordset")
outRS.Open "TableName", dbconn, adOpenStatic, adLockPessimistic

Do Until inRS.EOF
outRS.AddNew
outRS("field1") = inRS("fieldA")
outRS("field2") = inRS("fieldB")
... etc ...
outRS.Update
inRS.MoveNext
Loop
outRS.Close
inRS.Close
dbConn.Close
csvConn.Close
%>

THere are actually some even more efficient ways to do this, but without
know more of your details I'm hesitant to choose one. The above is simple
minded enough it should work so long as your CSV file doesn't have any
quirks.
Yep. Much more efficient is to simpy set up a connection to the Access
database, and then use a SQL statement like this:

INSERT INTO AccessTable (Field1, Field2, ...Fieldn) SELECT Col1, Col2,
....Coln FROM [Text;DATABASE=" & path_to_file & ";].[myfile.csv]

More info here: http://www.mikesdotnetting.com/Artic...x?ArticleID=67
(it's .NET - but the SQL etc is identical for classic ASP).

--
Mike Brind
MVP - ASP/ASP.NET
Jul 17 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Aliza Klein | last post by:
I am new to ASP so please pardon me if this is crazy. I have data that I want to allow the user to be able to save in a format that will then enable the user to open the data in Excel. (I have...
2
by: Kit Truong | last post by:
Hello, I have an asp page that produces output from a database. This allows a simple way for the user to save the data to a text file by going to File->Save as... The default save as options...
1
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table....
4
by: amywolfie | last post by:
I have a curious mission: I converted an Excel file to a relational Access 2002 database, and now I have to export data back to IT as a FLAT .csv file. I know how to create many records from...
4
by: Jae | last post by:
I'm writing a web application that exports and imports excel files. The application gets a list of users and their info and displays it in a datagrid .The user then selects to save the file as a...
1
by: new | last post by:
I have data for each week in a single table. I need to export this data to a separate flat file for each week. Any ideas? DB2 SQL Query export to flat files as a function of data on each record
2
by: vbaDev | last post by:
Hi. I am using Access 2000 and in my code I'm exporting a table into an Excel file (creating it), then the code needs to export another query into the same file (a new worksheet). So I needed both a...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
3
by: evenlater | last post by:
I have an Access application on a terminal server. Sometimes my users need to export reports to pdf, rtf or xls files and save them to their own client device hard drives. They can do that right...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.