Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2017
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Parse .lcra file to extract x and y values

    Hi,

    I exported raw data from a chromatography software called Trilution from Gilson. The file extension is .lcra but I was told that it is XML. I would like to re-produce plots from the raw data, however I cannot seem to extract/find what I need. I have been using R, however I know basic python. The file is 50 MB, and can be downloaded here: https://drive.google.com/file/d/0B6P...ew?usp=sharing
    It seems as though, all the data coalesces into the 4th node which makes it difficult to view/parse because it is very large. I think the data is within the <ValuesPeaks> node, and I want all the XValue and YValues. I tried subsetting, but that did not work, it just gives me NULL as a result. I do not have a programming background, so please be patient. Thank you.
    Code:
    require(xml)
    x<-'C15373_5_4509_11.lcra'
    xmltop<-xmlRoot(x)
    xmlName(xmltop)
    xmlSize(xmltop)
    xmltop[[4]]

  2. #2
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    3,499
    Thanks
    3
    Thanked 624 Times in 610 Posts
    Hi there sktrinh12,

    and a warm welcome to these forums.

    Bearing in mind that this is not my forte,
    I did manage to extract the XValue and the
    YValue attributes, all 18,280 of them

    The "C15373_5_4509_11.Icra" file needed to be
    saved as an xml file to work with javasvript.

    The code runs locally in Firefox but needs to be
    uploaded to a host server or a local server such
    as XAMPP for it to work in Chrome.

    This is the code that I used...

    Code:
    
    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">
    
    <title>XValue and YValue extraction</title>
    
    <style media="screen">
    #XYvalues {
        border-collapse: collapse;
     }
    #XYvalues th, #XYvalues td  {
        width: 10em;
        padding:0.5em 0;
        border: 0.062em solid #999;
        text-align: center;
     }
    </style>
    
    </head>
    <body>
    
     <script>
    (function() {
       'use strict';
    
       var req; 
       var xmlDoc;
       var tbl;
       var bdy;
       var peak;
       var tr;
       var th;
       var td;
       var v = ['XValue','YValue'];
       var c;
       var k;
    
    function loadXMLDoc(url) {
       req = false;
    if((window.XMLHttpRequest)&&!(window.ActiveXObject)) {
       try {
          req = new XMLHttpRequest();
     } 
       catch(e) {
          req = false; 
      }
     } 
    else {
    if(window.ActiveXObject) {
       xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
       xmlDoc.async = false;
       xmlDoc.load(url);
       processXml();
      }
     }
    if(req) {
       req.onreadystatechange=readyTest;
       req.open('GET', url, true);
       req.send('');
      }
     } 
    
    function readyTest() {
    if(req.readyState == 4) {
       xmlDoc = req.responseXML;
       processXml();
      }
     }
    function processXml() {
       tbl = document.createElement('table');
       tbl.setAttribute('id', 'XYvalues');
       bdy = document.createElement('body');
       tbl.appendChild(bdy);
       peak = xmlDoc.getElementsByTagName('Peak');
       tr = document.createElement('tr');
       th = document.createElement('th');
       th.appendChild(document.createTextNode('Number'));
       tr.appendChild(th);
    for(k = 0; k< 2; k++ ){
       th = document.createElement('th');
       th.appendChild(document.createTextNode(v[k]));
       tr.appendChild(th);
     }
       bdy.appendChild(tr);
    for(c = 0; c< peak.length; c++ ){
       tr = document.createElement('tr');
       td = document.createElement('td');
       td.appendChild(document.createTextNode(c+1));
       tr.appendChild(td);
    for(k = 0; k< 2; k++ ){
       td = document.createElement('td');
       td.appendChild(document.createTextNode( peak[c].getAttribute(v[k])));
       tr.appendChild(td);
     }
       bdy.appendChild(tr);
     }
       tbl.appendChild(bdy);
       document.body.appendChild(tbl);
     }
       loadXMLDoc('C15373_5_4509_11.xml');
    }());
    </script>
    
    </body>
    </html>

    coothead
    ~ the original bald headed old fart ~

  3. Users who have thanked coothead for this post:

    sktrinh12 (Jun 11th, 2017)

  4. #3
    New to the CF scene
    Join Date
    Jun 2017
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you for welcoming me to the forum, and your time in writing the code. I must admit, I do not understand your code let alone the language. I do not even know where to start in terms of replicating it to extract the x and y values Nevertheless, it gives me hope that the data can be extracted from the file.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •