LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read multiple excel files from folder

Solved!
Go to solution

Hi,

 

Thanks. Yes. 

 

Its working only single cell value. I will check it  further. I need to copy 10 locations from the file. 

0 Kudos
Message 11 of 28
(719 Views)

What is the ultimate "output" that you desire?  Are you looking for a "written Report", say, a Text file with outputs from various tests nicely formatted in rows and columns, with each Test preceded by a Serial Number, or do you want something to view on a screen that you can scroll around and see?  

 

I basically like @RamonG's use of a LabVIEW Table indicator which provides "alignment" possibilities, but the example he posted might not work with (some of) your Data Files.  For example, the Serial Number might not be on Line 13 (counting the top line as Line 1), and the number of sensors might not always be 10.

 

The Good News is that Read Delimited Spreadsheet (using a comma as the separator instead of the default <tab>) will, indeed, get all of the comma-delimited data into one large 2D (string) Array (assuming you chose the "String" form of Read Delimited Spreadsheet).  Now you can parse this array, looking for entries such as "SERIAL NUMBER" in the first (which I should call Column 0) column, and saving the (very long!) string found in the second column.  [You may or may not want to indicate, either as a separate column in the Report, that this is a Serial Number, and you'll probably also want to have a line that identifies which of the many Data Files these data come from].

 

You'll now need to parse the rest of the Report, looking for (say) a Blank line that separates various Tests.  I see a Test Summary -- do you want that?  Do you want a Test Identifier for the subsequent Tests in the Report?  Do you want to include all the Test Data, even if it is more than 10 entries?  How do you want the Report to be formatted (I'm guessing you'll want test data to be viewable as "columns", possibly right-justified, which is the default if the Data being placed in the table are really numeric, despite being read as strings (the Scan from String function Is Your Friend here).

 

Here is an idea that I've used when I've had data files that I wanted to save as text files for users who were more familiar with Excel and being able to read Text files -- I used Write Delimited Spreadsheet to output the mixed text-and-numeric data as a "delimited Spreadsheet", using a <tab> as the default separator.

 

To make this file "look pretty", I followed the following rules:

  • Header information were written one row at a time as a single entry, 1 row, 1 column
  • If I wanted a "sub-table" with Headers, I made the Headers 6 characters or less so they lined up when Tab-separated.
  • When writing data, put the column with data wider than 6 spaces last.
  • If there are multiple "clumps" of data (as in your case), output a blank (or a single space) row.

The nice thing is once you written the code to write this human-friendly data file, it is relatively straight-forward to engineer it to read this file and recover specific data (using Headers, if appropriate).

 

Bob Schor

Message 12 of 28
(701 Views)

Hi,

 

This is Vi 

Maheboob_0-1720802888439.png

This is the out. Everything is ok except Header name. Serial Number 

 

Maheboob_1-1720802975499.png

csv file out put

Maheboob_2-1720803721686.png

 

Expected csv out put as below. Check Highlighted color

Maheboob_3-1720803792458.png

 

 

 

0 Kudos
Message 13 of 28
(688 Views)

Create an Array of String that has what you want in the Header Row ([Serial Number, S1, S2, ... S40]).  Before you write the 2D Array of all of the Data, write the 1D Array that is the Header Row.Formatted Header.png

You do two writes -- one for the Header Row (here with "Serial Number" in the first column and then 20 columns S1 to S20 (you can make it 15, or 30), write it to the Output File first, then write all the data files as you have accumulated them.

 

Bpb Schor 

Message 14 of 28
(679 Views)

@Maheboob wrote:

Hi,

 

This is Vi 

Maheboob_0-1720802888439.png

This is the out. Everything is ok except Header name. Serial Number 

 


You don't need to wire all these indices, the 29 is all you need. Don't clutter the diagram!

Even simpler, just do the array subset!

 

altenbach_0-1720815038593.png

If you want headers, use another built array before writing the file and wire a 1D string array containing the headers. (A string array diagram constant if they are fixed, or else read from wherever that info is kept)

 

Message 15 of 28
(667 Views)

Dear Bob,

 

Please find my VI.

 

Maheboob_0-1720850551492.png

Please let me know how can i proceed further in order to get Header names. I really appreciate your support. Thank you.

0 Kudos
Message 16 of 28
(659 Views)

@Maheboob wrote:

Dear Bob,

 

Please find my VI.


This is based on my suggestion, not Bob.

 

 I already told you how to write the headers. I can't tell you where to get them because I don't know where the are.

Message 17 of 28
(655 Views)

Hi,

 

I am new to LV, just I know the basics of LV. I tried with your suggestion but it not working.

All serial numbers appearing before column. Can you create VI for me from my last VI to get the header names. Please refer my earlier email and attachment. Thanks 

0 Kudos
Message 18 of 28
(650 Views)

@Maheboob wrote:

I am new to LV, just I know the basics of LV. I tried with your suggestion but it not working.

There are billions of possible ways something is "not working". You need to be more specific.

 


@Maheboob wrote:

 

All serial numbers appearing before column. Can you create VI for me from my last VI to get the header names. Please refer my earlier email and attachment. Thanks 


I don't see any emails and this is a very long thread with many conflicting statements. Assuming the header you want is just [Serial Number, Sensr1, Sensor2, ... Sensor 10], here's one possibility:

 

altenbach_0-1720879303806.png

 

 

 

Message 19 of 28
(630 Views)
Solution
Accepted by topic author Maheboob

Here I use an array of files (I repeat the same file here, because you only attached one. You will have an array of file from "list folder", as shown earlier, of course and all files will be different)

 

altenbach_0-1720881037720.png

 

 

Message 20 of 28
(626 Views)