Hello,
I've a simple windows application and i want to be able to convert a csv
file to xml. So far, i can browse for the csv file from the file structure
and display in a textbox. I want to convert the displayed csv file in the
textbox to Xml and use the first line of the csv file as tags. I know there
will be different ways of doing this but i would like to keep it simple
because i am new to programming and the Visual Basic.Net environment. Any
help will be much appreciated.
Sample Input.csv
"Title", "Firstname" , "Surname"
"Miss", "Lisa", "Simpson"
"Mr", "Joe", "Bloggs"
"Mrs", "Maggie", "Simpson"
Sample output.xml
<Data>
<Address>
<Title>Miss</Title>
< Firstname>Lisa</ Firstname>
< Lastname>Simpso n</ Lastname>
</Address>
</Data>
Thanks........ 7 15045
Ish2000,
Have you looked at the XmlCsvReader? http://www.gotdotnet.com/Community/U...B-57A7DBBEBAE0
It reads a formatted file (such as CSV) as "Xml", this Xml should then be
easily parsed into your string1, integer1, double1 variables...
The "easiest" way might be to use XmlCsvReader to read the CSV into an XML
document, then use a normal XmlTextWriter to save the XML document to a
file.
Alternatively you should be able to do an identity transform with an XSLT
Transformation:
<xsl:transfor m version='1.0'
xmlns:xsl='http ://www.w3.org/1999/XSL/Transform'>
<xsl:template match='@*|node( )' >
<xsl:copy>
<xsl:apply-templates select='@*|node ()'/>
</xsl:copy>
</xsl:template>
</xsl:transform>
The above transformation is from http://msdn.microsoft.com/msdnmag/issues/0800/xslt/
Hope this helps
Jay
"Ish2000" <Is*****@discus sions.microsoft .com> wrote in message
news:F0******** *************** ***********@mic rosoft.com... Hello,
I've a simple windows application and i want to be able to convert a csv file to xml. So far, i can browse for the csv file from the file structure and display in a textbox. I want to convert the displayed csv file in the textbox to Xml and use the first line of the csv file as tags. I know there will be different ways of doing this but i would like to keep it simple because i am new to programming and the Visual Basic.Net environment. Any help will be much appreciated.
Sample Input.csv
"Title", "Firstname" , "Surname" "Miss", "Lisa", "Simpson" "Mr", "Joe", "Bloggs" "Mrs", "Maggie", "Simpson"
Sample output.xml
<Data> <Address> <Title>Miss</Title> < Firstname>Lisa</ Firstname> < Lastname>Simpso n</ Lastname> </Address> </Data>
Thanks........
Hi,
This code will create a csv file, load it into a dataset, and save
it as an xml file.
If Not Directory.Exist s("C:\CSV Test") Then
Directory.Creat eDirectory("C:\ CSV Test")
'
' Create a csv file
'
Dim sw As New StreamWriter("C :\CSV Test\Test.csv", False)
sw.WriteLine("C olumn1,Column2, Column3")
For x As Integer = 0 To 20
sw.WriteLine("{ 0},{0},{0}", x)
Next
sw.Close()
'
' Open an oledb connection and show it in a datagrid
'
Dim strConn As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=C:\CSV
Test;Extended Properties=""te xt;HDR=Yes;FMT= Delimited"""
Dim conn As New OleDb.OleDbConn ection(strConn)
Dim da As OleDb.OleDbData Adapter
Dim ds As New DataSet
Dim mycmd As New OleDb.OleDbComm and("Select * from Test.csv", conn)
Try
da = New OleDb.OleDbData Adapter(mycmd)
da.Fill(ds)
Catch ex As Exception
Trace.WriteLine (ex.ToString)
Return
End Try
DataGrid1.DataS ource = ds.Tables(0)
DataGrid1.Capti onText = "CSV Test"
ds.WriteXml("C: \CSV Test\CSV.xml")
Ken
------------------------------
"Ish2000" <Is*****@discus sions.microsoft .com> wrote in message
news:F0******** *************** ***********@mic rosoft.com...
Hello,
I've a simple windows application and i want to be able to convert a csv
file to xml. So far, i can browse for the csv file from the file structure
and display in a textbox. I want to convert the displayed csv file in the
textbox to Xml and use the first line of the csv file as tags. I know there
will be different ways of doing this but i would like to keep it simple
because i am new to programming and the Visual Basic.Net environment. Any
help will be much appreciated.
Sample Input.csv
"Title", "Firstname" , "Surname"
"Miss", "Lisa", "Simpson"
"Mr", "Joe", "Bloggs"
"Mrs", "Maggie", "Simpson"
Sample output.xml
<Data>
<Address>
<Title>Miss</Title>
< Firstname>Lisa</ Firstname>
< Lastname>Simpso n</ Lastname>
</Address>
</Data>
Thanks........
Ken,
That first part of your sample is in my opinion confusing, I was almost
giving a sample, when I saw that you in the middle started with the sample
that would have been almost the same as mine.
(as well meant for the OP of course)
Cor
Hi,
Sorry.
Ken
----------------
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:Ow******** ******@TK2MSFTN GP12.phx.gbl...
Ken,
That first part of your sample is in my opinion confusing, I was almost
giving a sample, when I saw that you in the middle started with the sample
that would have been almost the same as mine.
(as well meant for the OP of course)
Cor
Hi Ken,
My message was only to make you (and the OP) attent on it
Nothing to "Sorry" in my opinion, for you only for the next time, to make it
even better than it was.
:-)
Cor
Hi Jay,
Thanks for replying to my question. I've had a look at XmlCsvReader but the
source code is in C#. Can i get an XmlCsvReader in Visual Basic.Net?
thanks.....
"Jay B. Harlow [MVP - Outlook]" wrote: Ish2000, Have you looked at the XmlCsvReader?
http://www.gotdotnet.com/Community/U...B-57A7DBBEBAE0
It reads a formatted file (such as CSV) as "Xml", this Xml should then be easily parsed into your string1, integer1, double1 variables...
The "easiest" way might be to use XmlCsvReader to read the CSV into an XML document, then use a normal XmlTextWriter to save the XML document to a file.
Alternatively you should be able to do an identity transform with an XSLT Transformation:
<xsl:transfor m version='1.0' xmlns:xsl='http ://www.w3.org/1999/XSL/Transform'> <xsl:template match='@*|node( )' > <xsl:copy> <xsl:apply-templates select='@*|node ()'/> </xsl:copy> </xsl:template> </xsl:transform>
The above transformation is from http://msdn.microsoft.com/msdnmag/issues/0800/xslt/
Hope this helps Jay
"Ish2000" <Is*****@discus sions.microsoft .com> wrote in message news:F0******** *************** ***********@mic rosoft.com... Hello,
I've a simple windows application and i want to be able to convert a csv file to xml. So far, i can browse for the csv file from the file structure and display in a textbox. I want to convert the displayed csv file in the textbox to Xml and use the first line of the csv file as tags. I know there will be different ways of doing this but i would like to keep it simple because i am new to programming and the Visual Basic.Net environment. Any help will be much appreciated.
Sample Input.csv
"Title", "Firstname" , "Surname" "Miss", "Lisa", "Simpson" "Mr", "Joe", "Bloggs" "Mrs", "Maggie", "Simpson"
Sample output.xml
<Data> <Address> <Title>Miss</Title> < Firstname>Lisa</ Firstname> < Lastname>Simpso n</ Lastname> </Address> </Data>
Thanks........
Ish2000, Can i get an XmlCsvReader in Visual Basic.Net?
Not that I know of. However! I have to ask: Why would you *really* need it
in C#? (Remember, at the end of the day, both C# & VB.NET are simply
languages built upon .NET itself!)
Quickly looking at the package, you should be able to run the exe "As Is" to
convert a CSV to an XML document. (via Process.Start for example)
If you want to call the class directly yourself, I would recommend packaging
the XmlCsvReader class & any support classes in a C# class library assembly,
then referencing this assembly from your VB.NET project.
If you still really want VB.NET source there are any number of C# to VB.NET
converters available on the net.
Hope this helps
Jay
"Ish2000" <Is*****@discus sions.microsoft .com> wrote in message
news:6E******** *************** ***********@mic rosoft.com... Hi Jay,
Thanks for replying to my question. I've had a look at XmlCsvReader but the source code is in C#. Can i get an XmlCsvReader in Visual Basic.Net?
thanks.....
"Jay B. Harlow [MVP - Outlook]" wrote:
Ish2000, Have you looked at the XmlCsvReader?
http://www.gotdotnet.com/Community/U...B-57A7DBBEBAE0
It reads a formatted file (such as CSV) as "Xml", this Xml should then be easily parsed into your string1, integer1, double1 variables...
The "easiest" way might be to use XmlCsvReader to read the CSV into an XML document, then use a normal XmlTextWriter to save the XML document to a file.
Alternatively you should be able to do an identity transform with an XSLT Transformation:
<xsl:transfor m version='1.0' xmlns:xsl='http ://www.w3.org/1999/XSL/Transform'> <xsl:template match='@*|node( )' > <xsl:copy> <xsl:apply-templates select='@*|node ()'/> </xsl:copy> </xsl:template> </xsl:transform>
The above transformation is from http://msdn.microsoft.com/msdnmag/issues/0800/xslt/
Hope this helps Jay
"Ish2000" <Is*****@discus sions.microsoft .com> wrote in message news:F0******** *************** ***********@mic rosoft.com... > Hello, > > I've a simple windows application and i want to be able to convert a > csv > file to xml. So far, i can browse for the csv file from the file > structure > and display in a textbox. I want to convert the displayed csv file in > the > textbox to Xml and use the first line of the csv file as tags. I know > there > will be different ways of doing this but i would like to keep it simple > because i am new to programming and the Visual Basic.Net environment. > Any > help will be much appreciated. > > Sample Input.csv > > "Title", "Firstname" , "Surname" > "Miss", "Lisa", "Simpson" > "Mr", "Joe", "Bloggs" > "Mrs", "Maggie", "Simpson" > > Sample output.xml > > <Data> > <Address> > <Title>Miss</Title> > < Firstname>Lisa</ Firstname> > < Lastname>Simpso n</ Lastname> > </Address> > </Data> > > > Thanks........ > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: hunterb |
last post by:
I have a file which has no BOM and contains mostly single byte chars. There
are numerous double byte chars (Japanese) which appear throughout. I need to
take the resulting Unicode and store it in a DB and display it onscreen. No
matter which way I open the file, convert it to Unicode/leave it as is or
what ever, I see all single bytes ok, but double bytes become 2 seperate
single bytes. Surely there is an easy way to convert these mixed...
|
by: whatluo |
last post by:
Hi, all
I'm now working on a program which will convert dec number to
hex and oct and bin respectively, I've checked the clc but with no
luck, so can anybody give me a hit how to make this done without
strtol or s/printf function.
Thanks,
whatluo.
|
by: Daniel |
last post by:
I have looked everywhere on the web for an answer to this and the only
thing I can find is converting the image format when the file is
present on the local filesystem. What I want to do is use a web form
to upload a TIFF image (scanned images) and convert it to a JPEG
before I insert it into SQL Server. The file upload part works great,
but I can;t convert the image. I certainly don't want to upload it the
the server filesystem, convert...
|
by: Scott Schluer |
last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG)
to a B&W photo?
Thanks,
Scott
|
by: Thubaiti |
last post by:
Hi,
I have this code in my ASP.NET and I want to convert it to C# (code behind)
<asp:Repeater id="subCategoryRepeater" runat="server">
<ItemTemplate>
<ul>
<li>
<asp:HyperLink id="subCategoryHyperLink" runat="server" NavigateUrl='<%#
"subcategory.aspx?subcategoryid=" +
| |
by: Brian Henry |
last post by:
first question... I have a flat file which unfortinuatly has columns
seperated by nulls instead of spaces (a higher up company created it this
way for us) is there anyway to do a readline with this and not have it
affected by the null? because it is right now causes truncated data at wierd
places... but as soon as i manually with a hex editor change char(00) to
char(20) in the files it reads prerfectly... which leads me to my 2nd...
|
by: melickas |
last post by:
We designed a custom application using Office Developer Tools '97 which
included a Run-time version of Access--- so it would not matter if our
customer even had any version of Access on their computer. The
application ran without problems on our customer's computer for 2-3
years. Then our customer bought a new computer and we had to reinstall
the application. Everything was ok for approximately 6 months until our
customer was "cleaning up"...
|
by: PenguinPig |
last post by:
Dear All Experts
I would like to know how to convert a HTML into Image using C#. Or allow me
contains HTML code (parsed) in Image? I also tried this way but it just
display the character "<" & ">" directly....
I have done googling, but all return shareware. I would like to know how to
programming...but not using shareware...
Thanks all.
|
by: sonu |
last post by:
hey good morning ......
how to convert a video file in .flv format in php for linux
hosting......is there any package whis provide this facility .
Can i use ffmpeg for linux hosting project..........
plz help me..
thanks & regards
Prabhat
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
|
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...
| |
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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();...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |