Convert CSV to XML, HTML, JSON, and More

This article was written on October 07, 2010 by CyberNet.

convert csv xml html json.png

The other day I was looking for a way to take a large CSV file worth of data and convert it into corresponding XML nodes. I wanted the first line of the CSV file to serve as each individual node name so that it could be easily parsed, and most of all I wanted an online solution because I knew I shouldn’t need a full-fledged application to do something this mundane.

After a few quick searches I came across Mr. Data Converter. It’s an awesome utility that lets you paste in any CSV (comma separated values) or tab-delimited data, and it will turn it into one of nine different formats. A full list of compatible formats are below, and notably include HTML, XML, and JSON.

To put the data converter to the test I went ahead and created a very brief CSV file that I could pass through the service to examine what the output looks like. Here’s the CSV content that I started with:

Name,Class,Age,Grade
Jason,Math,14,A
Beth,English,16,B+
Anne,Math,15,A+

And this is the resulting output for all of the supported types:

  • Actionscript
    [{name:"Jason",class:"Math",age:"14",grade:"A"},
    {name:"Beth",class:"English",age:"16",grade:"B+"},
    {name:"Anne",class:"Math",age:"15",grade:"A+"}];
  • ASP/VBScript
    Dim myArray(3,2)
    myArray(0,0) = "Jason"
    myArray(1,0) = "Math"
    myArray(2,0) = "14"
    myArray(3,0) = "A"
    myArray(0,1) = "Beth"
    myArray(1,1) = "English"
    myArray(2,1) = "16"
    myArray(3,1) = "B+"
    myArray(0,2) = "Anne"
    myArray(1,2) = "Math"
    myArray(2,2) = "15"
    myArray(3,2) = "A+"
  • HTML
    <table>
      <thead>
       <tr>
        <th class="name-cell">name</th>
        <th class="class-cell">class</th>
        <th class="age-cell">age</th>
        <th class="grade-cell">grade</th>
       </tr>
      </thead>
      <tbody>
       <tr class="firstRow">
        <td class="name-cell">Jason</td>
        <td class="class-cell">Math</td>
        <td class="age-cell">14</td>
        <td class="grade-cell">A</td>
       </tr>
       <tr>
        <td class="name-cell">Beth</td>
        <td class="class-cell">English</td>
        <td class="age-cell">16</td>
        <td class="grade-cell">B+</td>
       </tr>
       <tr class="lastRow">
        <td class="name-cell">Anne</td>
        <td class="class-cell">Math</td>
        <td class="age-cell">15</td>
        <td class="grade-cell">A+</td>
       </tr>
      </tbody>
    </table>
  • JSON – Properties
    [{"name":"Jason","class":"Math","age":"14","grade":"A"},
    {"name":"Beth","class":"English","age":"16","grade":"B+"},
    {"name":"Anne","class":"Math","age":"15","grade":"A+"}];
  • JSON – Array
    [["Jason","Math","14","A"],
    ["Beth","English","16","B+"],
    ["Anne","Math","15","A+"]];
  • PHP
    array(
    array("name"=>"Jason","class"=>"Math","age"=>"14","grade"=>"A"),
    array("name"=>"Beth","class"=>"English","age"=>"16","grade"=>"B+"),
    array("name"=>"Anne","class"=>"Math","age"=>"15","grade"=>"A+")
    );
  • Ruby
    [{"name"=>"Jason","class"=>"Math","age"=>"14","grade"=>"A"},
    {"name"=>"Beth","class"=>"English","age"=>"16","grade"=>"B+"},
    {"name"=>"Anne","class"=>"Math","age"=>"15","grade"=>"A+"}];
  • XML – Properties
    <?xml version="1.0" encoding="UTF-8"?>
    <rows>
      <row name="Jason" class="Math" age="14" grade="A" ></row>
      <row name="Beth" class="English" age="16" grade="B+" ></row>
      <row name="Anne" class="Math" age="15" grade="A+" ></row>
    </rows>
  • XML – Nodes
    <?xml version="1.0" encoding="UTF-8"?>
    <rows>
      <row>
        <name>Jason</name>
        <class>Math</class>
        <age>14</age>
        <grade>A</grade>
      </row>
      <row>
        <name>Beth</name>
        <class>English</class>
        <age>16</age>
        <grade>B+</grade>
      </row>
      <row>
        <name>Anne</name>
        <class>Math</class>
        <age>15</age>
        <grade>A+</grade>
      </row>
    </rows>

Pretty awesome, huh? This also makes a handy programming tool since it is able to create arrays for Ruby, PHP, ASP, and even ActionScript. Oh, and if you’re using Microsoft Excel you can just highlight the cells you want to use, copy them, and they will be pasted into the data converter using a format it understands. With that in mind you can actually use Excel functions to help generate random testing data, and then use the convert to get it into the format you need.

Mr. Data Converter Homepage

Copyright © 2010 CyberNet | CyberNet Forum | Learn Firefox

Related Posts:


AT&T clarifies Windows Phone 7 launch parameters: no pre-orders, online sales are a go

November 8th is creeping ever closer, and aside from it marking the beginning of yet another long, drawn-out week in the working world, it’s also the first day you can get your paws around a Windows Phone 7 device from AT&T. Much in the same way that it did before subsequent iPhone launches, the carrier has come forward with a few vital pieces of information to chew on before making any incorrect assumptions. Company representative Warner May confirmed to Phone Scoop that online sales for Windows Phone 7 devices (the Samsung Focus and HTC Surround) would indeed go live on launch day, debunking rumors that the phones would only be available for the grabbing in retail locations. Furthermore, we’re told that no pre-orders are being accepted via B&M / online — a logical move given the chaos that ensued from the iPhone 4 pre-order rush. More on the launch as we get it.

AT&T clarifies Windows Phone 7 launch parameters: no pre-orders, online sales are a go originally appeared on Engadget on Sat, 06 Nov 2010 02:55:00 EDT. Please see our terms for use of feeds.

Permalink   |  sourcePhonescoop  | Email this | Comments

Ask Giz: Four Loko Frenzy, Budget Sextapes, and an Identity Crisis [Askgiz]

A friend turned drunken thief. A couple looking for some on-camera action. A digital dater racked with shame. You seem guilty, this week, readers. But our consciences are filthy too—all aboard the empathy train. It’s time for healing. More »

Nokia N8 going on general sale October 22, available online October 15

Been waiting for the N8 but weren’t sure enough about buying it to get into the pre-order queue? Well, Nokia must have found your lack of faith disturbing as it’s now stiffing those who didn’t pre-order its all-new handset with another couple of weeks of waiting. Those without Nokia logos tattooed on their lower backs will finally be able to purchase the N8 on October 15 — but only via Nokia’s own web store — before a general release hits the UK and presumably most of the rest of Europe on October 22 (slightly later than the promised October 1 landing date). The distribution is indeed wide, however, with all the major UK carriers, plus Tesco Mobile and Virgin Mobile, joining the Carphone Warehouse and Phones 4U in offering the phone that has “a black belt in entertainment.” Yeah, Nokia, we’re finding this wait really entertaining.

Continue reading Nokia N8 going on general sale October 22, available online October 15

Nokia N8 going on general sale October 22, available online October 15 originally appeared on Engadget on Wed, 06 Oct 2010 03:49:00 EDT. Please see our terms for use of feeds.

Permalink   |   | Email this | Comments

Another AppStore; This Time from Intel

find-appsintel.jpg

We don’t need yet another online app store. Consumers are surrounded by them, and developers don’t want yet another store they have to learn to develop for. But Intel went ahead with its plans and the AppUp center is nearing reality.

Currently available only to folks with a Intel-processor based netbook running Windows (talk about a very specific target audience), AppUp will sell Adobe Air and  Microsoft Silverlight applications, as well as apps from Barnes & Noble, KONAMI, Accuweather, and Gibson Guitars.

The store will offer free and paid apps. There will be a “try before you buy” option to weed out undesirable apps.

Google music service might offer subscriptions as well as digital downloads

We know that Google’s been thinking about launching a music service, and now the crazy kids at Billboard are reporting details of a proposal that the search giant’s been circulating among the major labels. Apparently the company is pursuing a sort of hybrid digital download store / cloud-based locker service, with the store offering individual tracks or albums, while the “locker” would scan the user’s hard drive for music files and, upon finding tracks that Google is licensed to offer, allow the user access to them on the cloud (presumably you won’t be actually uploading your MP3s to the service, just streaming their content once it’s determined you have a copy of your own). And since you can’t offer any service without a little “social networking” on the side these days, Google would like to give users the opportunity to send each other tracks, which they could listen to once — and then either purchase or preview (um, review) in thirty second snippets, similar to Lala. There’s no word yet on which — if any — labels are willing to take the bait, but we’ll let you know as soon as we hear anything else. Promise.

Google music service might offer subscriptions as well as digital downloads originally appeared on Engadget on Wed, 15 Sep 2010 18:43:00 EDT. Please see our terms for use of feeds.

Permalink   |  sourceBillboard  | Email this | Comments

Sony ponders charging for ‘online pass’ game functionality

We specifically told you guys not to tell your friends at Sony about a certain “feature” of EA Sports whereby the player is charged $10 to unlock online content and multiplayer functionality. And what do we have here? It looks like someone spilled the beans, because GamesIndustry.biz is reporting that Sony Computer Entertainment head Andrew House has been giving the matter some serious thought. “On the principle of making online portions of the game available or unlocked from the disc-based release for a fee,” he said, “we’re broadly supportive… and we’re exploring actively the same option for our own content.” Of course, this runs counter the free and democratic nature of PlayStation Network, but you know how strategies can change once someone gets dollar signs in their eyes.

Sony ponders charging for ‘online pass’ game functionality originally appeared on Engadget on Wed, 25 Aug 2010 01:33:00 EDT. Please see our terms for use of feeds.

Permalink Engadget Spanish, Joystiq  |  sourceGameIndustry.biz  | Email this | Comments

Google setting up music store later this year, looking for search and Android synergy

Remember that chart that pointed out the differences between Google, Apple and Microsoft? Well, it’s looking increasingly like Google is intent on filling any and all gaps in its portfolio. Those good old unnamed sources have been talking, originally to CNET last week and to the Wall Street Journal today, and disclosing Google’s supposed intent to introduce its very own music store. This would initially encompass a web store where you can stream or download tracks, with a search tie-in that’ll get your money into Google’s pocket in the fastest possible way. Subsequent plans are said to include Android integration in 2011 — something that Google rather nonchalantly demoed at its I/O conference last month. Of course, none of this is as yet confirmed, but it looks like Apple and Google will be competing across yet another front — hold on tight.

Google setting up music store later this year, looking for search and Android synergy originally appeared on Engadget on Tue, 22 Jun 2010 08:54:00 EDT. Please see our terms for use of feeds.

Permalink   |  sourceCNET, Wall Street Journal  | Email this | Comments

OnLive turns sentient, now beaming gaming goodness over the ether (update)

We were promised cloud gaming nirvana on June 17, and OnLive has indeed kept to its self-imposed schedule. The new service that allows you to play resource-hungry games via only your browser window has taken its first steps into the real (non-beta) world with an initial catalog of 23 games. It’ll be free for the first year for those who showed faith early on and pre-registered, or $15 per month for new bandwagon riders. Do let us know your thoughts if you’ve gotten onboard at this nascent stage: does it play fantastically well, is it close to spectacular, or is it just a pedestrian effort aiming to capitalize on geeks’ lust for unbound gaming? We have to know.

[Thanks, Mike]

Update: OnLive’s site doesn’t seem to have been updated to reflect the service going live (you can sign up, but can’t just jump in and play). It might be, therefore, that OnLive is booting itself up in stages, with only the early birds getting the first bite.

OnLive turns sentient, now beaming gaming goodness over the ether (update) originally appeared on Engadget on Fri, 18 Jun 2010 04:28:00 EDT. Please see our terms for use of feeds.

Permalink   |  sourceYahoo! News  | Email this | Comments

Showtime getting ready to go online?

What’s a “premium” movie service these days without access on additional screens? Not much, which is probably why rumors indicate Showtime is about to follow EPIX HD and ESPN 3(no 60) by creating an online service for subscribers to view on their PCs and mobile devices. Don’t expect to watch Weeds, Dexter and The Real L Word on your iPad just yet (except for what’s already available on Netflix) as a spokeswoman had only a standard “nothing to announce to” offer Bloomberg Businessweek, but their sources indicate it will resemble the HBO GO service we tested out recently when it went live for Verizon FiOS TV customers. Heading online seems like a good followup to turning on interactive HDTV features, but we’ll see if that’s enough to keep viewers signing up for its service when there are so many alternatives available.

Showtime getting ready to go online? originally appeared on Engadget on Mon, 10 May 2010 16:31:00 EST. Please see our terms for use of feeds.

Permalink   |  sourceBloomberg Businessweek  | Email this | Comments