473,763 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.csv File to .xml File in VB.Net using 2.0 Framework and .xsd

TC
Hey All,

I've been searching for a code snippet, not a 3rd party tool, that takes a
..csv file and transforms it to an .xml file based upon an .xsd.

Can anyone point me in the right direction or provide a code snippet?

I would prefer vb.net but C# is fine too or even pseudo code with
appropriate .Net objects and example.

Thanks,

TC
Jun 27 '08 #1
4 4388
TC,

A CSV has no XSD, and there is not even a relatieon, how did you want to do
this, without a XSD it is simple,

http://www.vb-tips.com/dbpages.aspx?Search=csv

To make it an xml file you do simple

ds.WriteXML(pat h)

Cor
"TC" <ge**********@y ahoo.comschreef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Hey All,

I've been searching for a code snippet, not a 3rd party tool, that takes a
.csv file and transforms it to an .xml file based upon an .xsd.

Can anyone point me in the right direction or provide a code snippet?

I would prefer vb.net but C# is fine too or even pseudo code with
appropriate .Net objects and example.

Thanks,

TC
Jun 27 '08 #2
TC
Hey Cor,

I know that XSD has nothing to do with .csv ;-)

I meant applying the .xsd to the .xml file that was created from the .csv
file.

I also agree, that I need to go from .csv to dataset and then use the
ability to write the .xml file from there.

Thanks,

TC
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:FA******** *************** ***********@mic rosoft.com...
TC,

A CSV has no XSD, and there is not even a relatieon, how did you want to
do this, without a XSD it is simple,

http://www.vb-tips.com/dbpages.aspx?Search=csv

To make it an xml file you do simple

ds.WriteXML(pat h)

Cor
"TC" <ge**********@y ahoo.comschreef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>Hey All,

I've been searching for a code snippet, not a 3rd party tool, that takes
a .csv file and transforms it to an .xml file based upon an .xsd.

Can anyone point me in the right direction or provide a code snippet?

I would prefer vb.net but C# is fine too or even pseudo code with
appropriate .Net objects and example.

Thanks,

TC

Jun 27 '08 #3

"TC" <ge**********@y ahoo.comwrote in message
news:OA******** ******@TK2MSFTN GP02.phx.gbl...
Hey Cor,

I know that XSD has nothing to do with .csv ;-)

I meant applying the .xsd to the .xml file that was created from the .csv
file.

I also agree, that I need to go from .csv to dataset and then use the
ability to write the .xml file from there.

Thanks,

TC
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:FA******** *************** ***********@mic rosoft.com...
>TC,

A CSV has no XSD, and there is not even a relatieon, how did you want to
do this, without a XSD it is simple,

http://www.vb-tips.com/dbpages.aspx?Search=csv

To make it an xml file you do simple

ds.WriteXML(pa th)

Cor
"TC" <ge**********@y ahoo.comschreef in bericht
news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
>>Hey All,

I've been searching for a code snippet, not a 3rd party tool, that takes
a .csv file and transforms it to an .xml file based upon an .xsd.

Can anyone point me in the right direction or provide a code snippet?

I would prefer vb.net but C# is fine too or even pseudo code with
appropriate .Net objects and example.

Thanks,

TC

Ok first things first:

Create a dataset from a .csv

1. Create an ODBC datasource to the folder in which your .csv file exists
Open the ODBC Data Source Administrator
Either use User DSN or System DSN (I will use User)
Click Add
In the Select a driver - Select MS Access Text Driver(*.txt, *.csv)
Click Finish
Input a Data Source Name (and description if you want)
Now unclick "Use Current Directory" and use Select Directory to get
directory holding .csv
Go to options. This is where you can select what file extensions will
be used (if no .txt files just cancel)

2. Open VS if not already open
3. View/Server Explorer
4. Right click Data Connection and select Add Connection
5 Change DataSource to MS ODBC Data Source - OK
6. From dropdown of User/System data source choose your new source
created above
7. You now have a Data Connection to your .csv

8. Add New Item to project - Dataset (name it accordingly)
9. Open (click +) on your dataconnection (Server Explorer)
Open tables and you should see your .csv file
10. Drag it to the .xsd designer (if you have column names in the .csv you
will get column names in the dataset)

You now have a dataset which you can use

Hope this helps
Lloyd Sheen

Jun 27 '08 #4
Just use a filestream and parse the CSV into XML yourself, sheesh. It's not
that hard!
--
David Streeter
Synchrotech Software
Sydney Australia
"Lloyd Sheen" wrote:
>
"TC" <ge**********@y ahoo.comwrote in message
news:OA******** ******@TK2MSFTN GP02.phx.gbl...
Hey Cor,

I know that XSD has nothing to do with .csv ;-)

I meant applying the .xsd to the .xml file that was created from the .csv
file.

I also agree, that I need to go from .csv to dataset and then use the
ability to write the .xml file from there.

Thanks,

TC
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:FA******** *************** ***********@mic rosoft.com...
TC,

A CSV has no XSD, and there is not even a relatieon, how did you want to
do this, without a XSD it is simple,

http://www.vb-tips.com/dbpages.aspx?Search=csv

To make it an xml file you do simple

ds.WriteXML(pat h)

Cor
"TC" <ge**********@y ahoo.comschreef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Hey All,

I've been searching for a code snippet, not a 3rd party tool, that takes
a .csv file and transforms it to an .xml file based upon an .xsd.

Can anyone point me in the right direction or provide a code snippet?

I would prefer vb.net but C# is fine too or even pseudo code with
appropriate .Net objects and example.

Thanks,

TC


Ok first things first:

Create a dataset from a .csv

1. Create an ODBC datasource to the folder in which your .csv file exists
Open the ODBC Data Source Administrator
Either use User DSN or System DSN (I will use User)
Click Add
In the Select a driver - Select MS Access Text Driver(*.txt, *.csv)
Click Finish
Input a Data Source Name (and description if you want)
Now unclick "Use Current Directory" and use Select Directory to get
directory holding .csv
Go to options. This is where you can select what file extensions will
be used (if no .txt files just cancel)

2. Open VS if not already open
3. View/Server Explorer
4. Right click Data Connection and select Add Connection
5 Change DataSource to MS ODBC Data Source - OK
6. From dropdown of User/System data source choose your new source
created above
7. You now have a Data Connection to your .csv

8. Add New Item to project - Dataset (name it accordingly)
9. Open (click +) on your dataconnection (Server Explorer)
Open tables and you should see your .csv file
10. Drag it to the .xsd designer (if you have column names in the .csv you
will get column names in the dataset)

You now have a dataset which you can use

Hope this helps
Lloyd Sheen

Jun 27 '08 #5

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

Similar topics

1
1028
by: santhosh_176 | last post by:
:I Created a Pocket PC application for iPAQ 5450. Every thing went fine even installer creation. I could run the setup and install it into the actual device and worked fine. The application enables syncronization with remote database using merge replication. I found contradictory results while installing the application. I will mention here all the steps that I done while creating and installing setups. Result: Case 1: worked fine. ...
3
12181
by: Michael Bøcker-Larsen | last post by:
Hi I'v been stuck on this problem for ages now. I have found that I'm not the only one with this problem, by looking through the different newsgroups. Hope you can help me! I know there is a lot of information, but if you need more (e.g. the code) please write michael@mblarsen.dk. The problem is this error messages (the code is build just fine; no errors):
6
2858
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked fine while the file was in the project directory. When the obsolete file was removed from the project directory, my application will no longer compile. Can someone please help with this issue? Thank in advance, Tom
14
3894
by: Al Smith | last post by:
I need help in implementing proper error handling. I am trying to upload a file based on the sample code below. The code works well except if the file selected is too big. I do know about the maxRequestLength parameter of the <httpRuntime> section and that works as expected. What I want is to enforce a max file size but haven't been able to trap the error thrown when the file is too large and that's where I could use some help.
2
2656
by: Anna | last post by:
I added a small Web.Config file to the root of my website so that I could view errors on a machine other than the server: <configuration> <system.web> <customErrors mode="Off" /> </system.web> </configuration> However, this immediately threw a different error when I tried to view
15
4778
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is not validate based on some given rules. I also have a custom error handling page to show the...
15
2835
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. Everything is the default settings I believe. IIS is running under Local System. In IIS the DefaultAppPool is running under Network Service. Annonymous access uses the account IUSR_JASMINE (machine name is Jasmine).
3
5061
by: Mike Kelly | last post by:
Hi. I've built a page using standard ASP.NET 2.0 features and when I upload a large file (>20MB) to our intranet server, I get a paltry 100KB/s on our 100Mb/s LAN. Simply copying the file, I get around 7MB/s. I'm using a FileUpload control on an .aspx page, and then I'm writing the MyFileUpload.PostedFile.InputStream off to a database. What can I do to speed up this uploading? Thanks in advance
17
8029
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: I am trying to use the SaveFileDialog class to get a filename, which is subsequently opened for writing (write access, read sharing, but using read/write sharing doesn't make the problem go away anyway). Sometimes, on the statement where I...
7
2832
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= | last post by:
Hi, I have been using the code (some of it has been removed for simplicity) below to allow authenticated (using ASP.NET membership database) users to get a file from their archive area. It seems to work fine, however I noticed that no web log entry is added when a successful download occurs (normally a 200 HTTP status code, however, if there is an authorization failure, it gets logged). I have a logging routine that logs a successful...
0
9566
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9389
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10149
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8825
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7370
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5271
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5410
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3918
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.