Average Data from multiple text files
I am new to labVIEW hence a little help is appreciated:
I have a 100 txt files with two columns (tab separated) for X and Y value.
I need to average the Y values to generate one single txt file and generate X versus Y graph.
So how do I read the data from these text files? (without having to select each one of them individually) and how to average the data and create a XY graph from it?
Thanks in advance
Solved!
Go to Solution.
Use X-Y Graph.
You were able to get two arrays of X and Y points from text file right?
Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
Similar Messages
-
Extracting specific data from multiple text files to single CSV
Hello,
Unfortunately my background is not scripting so I am struggling to piece together a powershell script to achieve the below. Hoping an experienced powershell scripter can provide the answer. Thanks in advance.
I have a folder containing approx. 2000 label type files that I need to extract certain information from to index a product catalog. Steps to be performed within the script as I see are:
1. Search folder for *.job file types
2. Search the files for certain criteria and where matched return into single CSV file
3. End result should be a single CSV with column headings:
a) DESCRIPTION
b) MODEL
c) BARCODETry:
# Script to extract data from .job files and report it in CSV
# Sam Boutros - 8/24/2014
# http://superwidgets.wordpress.com/category/powershell/
$CSV = ".\myfile.csv" # Change this filename\path as needed
$Folders = "d:\sandbox" # You can add multiple search folders as "c:\folder1","\\server\share\folder2"
# End Data entry section
if (-not (Test-Path -Path $CSV)) {
Write-Output """Description"",""Model"",""Barcode""" | Out-File -FilePath $CSV -Encoding ascii
$Files = Get-ChildItem -Path $Folders -Include *.job -Force -Recurse
foreach ($File in $Files) {
$FileContent = Get-Content -Path $File
$Keyword = "viewkind4"
if ($FileContent -match $Keyword) {
for ($i=0; $i -lt $FileContent.Count; $i++) {
if ($FileContent[$i] -match $Keyword) {
$Description = $FileContent[$i].Split("\")[$FileContent[$i].Split("\").Count-1]
} else {
Write-Host "Keyword $Keyword not found in file $File" -ForegroundColor Yellow
$Keyword = "Code:"
if ($FileContent -match $Keyword) {
for ($i=0; $i -lt $FileContent.Count; $i++) {
if ($FileContent[$i]-match $Keyword) {
$Parts = $FileContent[$i].Split(" ")
for ($j=0; $j -lt $Parts.Count; $j++) {
if ($Parts[$j] -match $Keyword) {
$Model = $Parts[$j+1].Trim()
$Model = $Model.Split("\")[$Model.Split("\").Count-1]
} else {
Write-Host "Keyword $Keyword not found in file $File" -ForegroundColor Yellow
$Keyword = "9313"
if ($FileContent -match $Keyword) {
for ($i=0; $i -lt $FileContent.Count; $i++) {
if ($FileContent[$i] -match "9313") {
$Index = $FileContent[$i].IndexOf("9313")
$Barcode = $null
for ($j=0; $j -lt 12; $j++) {
$Barcode += $FileContent[$i][($Index+$j)]
} else {
Write-Host "Keyword $Keyword not found in file $File" -ForegroundColor Yellow
Write-Output "File: '$File', Description: '$Description', Model: '$Model', Barcode: '$Barcode'"
Write-Output """$Description"",""$Model"",""$Barcode""" | Out-File -FilePath $CSV -Append -Encoding ascii
Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) -
Error in importing data from multiple ASCii files, Concatenat​e
I am trying to use the "Importing Data From Multiple ASCII FIles.VBS" and the "Concatenate Groups.VBS" scripts downloaded from here, http://zone.ni.com/devzone/cda/epd/p/id/3870. When I run the importing data script and test it by highlighting the example data that comes with the download I get an error. "Error in <Importing Data From Multiple ASCII Files.VBS> (Line:60, Column: 11): Variabls is undefined: 'AscIIAssocSet' "
The offending line of code is " Call AsciiAssocSet(FilePaths(i), StpFilePath) ' assign STP file "
Screenshots of the error are attached.
Can anyone tell me what this error is? Am I just doing something wrong? Getting quite frustrated.
Thanks in advance.
Attachments:
concactenate1.png 261 KB
concactenate2.png 243 KBPlease have a look at the DIAdem Example to concanate channels. Its delivered with DIAdem.
Examples > Creating Scripts > Scripts > Appending Channels to Each Other
Please use a dataplugin (File -> Text DataPlugin Wizard...) or the csv plugin to load your data.
Greetings
Andreas
P.S.: The one you have downloaded needs the old Ascii Wizard that is not activated by default in newer DIAdem versions.
If you want to use it anyway:
Settings -> Options -> Extensions -> GPI Extensions ...
Add gfsasci.dll -
How to load Test data from a Text file in ECATT
Hi,
I have created a test configuration with a test script, system data container, and test data container.
I have done the recording of a transaction and created the script. Parameterization is done for the script and have imported those parameters from script in to the data container.
I am trying to load a the data from a text file on the local work-station. The data is not being read.
Please explain this in detail (step by step) as I am very new to ECATT.
I am trying this on SAP ECC 6.0 IDES server.
Thanks in Advance
Vikas PatilPlease explain this in detail (step by step) as I am very new to ECATT.
Thanks in Advance
Vikas Patil -
How do you read data from a text file into a JTextArea?
I'm working on a blogging program and I need to add data from a text file named messages.txt into a JTextArea named messages. How do I go about doing this?
Student_Coder wrote:
1) Read the file messages.txt into a String
2) Initialize messages with the String as the textSwing text components are designed to use Unix-style linefeeds (\n) as line separators. If the text file happens to use a different style, like DOS's carriage-return+linefeed (\r\n), it needs to be converted. The read() method does that, and it saves the info about the line separator style in the Document so the write() method can re-convert it.
lethalwire wrote:
They have 2 different ways of importing documents in this link:
http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
Neither of those methods applies to JTextAreas. -
I would like to plott data from a text file in the same way as a media player does from a video file. I’m not sure how to create the pointer slide function. The vi could look something like the attached jpg.
Please, can some one help me?
Martin
Attachments:
Plotting from a text file like a media player example.jpg 61 KBHI Martin,
i am not realy sure what you want!?!?
i think you want to display only a part of the values you read from XYZ
so what you can do:
write all the values in an array.
the size of the array is the max. value of the slide bar
now you can select a part of the array (e.g. values from 100 to 200) and display this with a graph
the other option is to use the history function of the graphes
regards
timo -
How to parse data from a text file with no convenient delimiters?
I need to read data from a text file. This file contains one line of data with the repeating pattern "time 00 ADVar2: ___ Height: ____ time 01 ADVar2: ___ Height: ___ ..." I need LabView to parse out the "time" and "height" values, build an array with the values, and graph the correlation on an X&Y plot. Does Labview have an automated way to read to the input data file and parse out the correct values, even without convenient delimiters? Thank you.
You actually do have a convenient delimiter: "time". Thus, you can make an array using that as the delimiter. Only caveat is that the first array element will be empty. Then you can conveniently use the Scan From String function in a for-loop. Something like this:
Message Edited by smercurio_fc on 11-21-2008 03:13 PM
Attachments:
Example_VI.png 9 KB -
Hi,
I have to implement the following scenario in SSIS but don't know how to do since I never worked with SSIS before. Please help me.
I have 20 different text files in a single folder and 20 different tables corresponding to each text file in SQL Server 2008 R2 Database. I need to extract the data from each text file and
load the data into corresponding table in Sql Server Database. Please guide me in how many ways I can do this and which is the best way to implement this job. Actually I have to automate this job. Few files are in same format(with same column names
and datatypes) where others are not.
1. Do I need to create 20 different projects ?
or
Can I implement this in only one project by having 20 packages?
or
Can I do this in one project with only one package?
Thanks in advance.As I said I don't know how to use object data type, I just given a shot as below. I know the following code has errors can you please correct it for me.
Public
Sub Main()
' Add your code here
Dim f1
As FileStream
Dim s1
As StreamReader
Dim date1
As
Object
Dim rline
As
String
Dim Filelist(1)
As
String
Dim FileName
As
String
Dim i
As
Integer
i = 1
date1 =
Filelist(0) =
"XYZ"
Filelist(1) =
"123"
For
Each FileName
In Filelist
f1 = File.OpenRead(FileName)
s1 = File.OpenText(FileName)
rline = s1.ReadLine
While
Not rline
Is
Nothing
If Left(rline, 4) =
"DATE"
Then
date1 (i)= Mid(rline, 7, 8)
i = i + 1
Exit
While
End
If
rline = s1.ReadLine
End
While
Next
Dts.Variables(
"date").Value = date1(1)
Dts.Variables(
"date1").Value = date1(2)
Dts.TaskResult = ScriptResults.Success
End
Sub -
Read data from a text file, one line at a time.
I need to read data from a text file, and display each line in a String Indicator on Front Panel. It displays each line, but I get Error 4, End Of Line, unless I enter an extra line of data in the file that I don't need. I tried Read From Text File.vi, made by Nat Instr, and it gave the same error.
The Read from Text File.vi reads data from a text file line by line until the user stops the VI manually with the Stop button on the front panel, or until an error (such as "Error 4, End of file") occurs. If an error occurs, the Simple Error Handler.vi pops up a dialog that tells you which error occurred.
The Read from Text File.vi uses a while loop, but if you knew how many lines you wanted to read, you could replace the while loop with a for loop set to read that many lines from the file.
If you need something more dynamic because the number of lines in your files vary, then you could change the code of the Read from Text File.vi to the expect "Error 4, End of file" and handle it appropriately. This would require unbundling the error cluster that comes fro
m the Read File function with the Unbundle By Name function, so that you can expose the individual error "status" and error "code" values stored in the cluster. If the value of the error "code" is 4, then you can change the error "status" from true to false, and you can rebundle the cluster with the Bundle by Name function. Setting the error "status" to false instructs the Simple Error Handler to ignore the error. Otherwise, pass the original error cluster to the Simple Error Handler.vi, so that you can see what the error is.
Of course, if you're not interested in what the errors are, you could just remove the Simple Error Handler.vi, but then you wouldn't see any error messages.
Best of Luck,
Dieter
Dieter Schweiss
Applications Engineer
National Instruments -
How can I use Automator to extract specific Data from a text file?
I have several hundred text files that contain a bunch of information. I only need six values from each file and ideally I need them as columns in an excel file.
How can I use Automator to extract specific Data from the text files and either create a new text file or excel file with the info? I have looked all over but can't find a solution. If anyone could please help I would be eternally grateful!!! If there is another, better solution than automator, please let me know!
Example of File Contents:
Link Time =
DD/MMM/YYYY
Random
Text
161 179
bytes of CODE memory (+ 68 range fill )
16 789
bytes of DATA memory (+ 59 absolute )
1 875
bytes of XDATA memory (+ 1 855 absolute )
90 783
bytes of FARCODE memory
What I would like to have as a final file:
EXCEL COLUMN1
Column 2
Column3
Column4
Column5
Column6
MM/DD/YYYY
filename1
161179
16789
1875
90783
MM/DD/YYYY
filename2
xxxxxx
xxxxx
xxxx
xxxxx
MM/DD/YYYY
filename3
xxxxxx
xxxxx
xxxx
xxxxx
Is this possible? I can't imagine having to go through each and every file one by one. Please help!!!Hello
You may try the following AppleScript script. It will ask you to choose a root folder where to start searching for *.map files and then create a CSV file named "out.csv" on desktop which you may import to Excel.
set f to (choose folder with prompt "Choose the root folder to start searching")'s POSIX path
if f ends with "/" then set f to f's text 1 thru -2
do shell script "/usr/bin/perl -CSDA -w <<'EOF' - " & f's quoted form & " > ~/Desktop/out.csv
use strict;
use open IN => ':crlf';
chdir $ARGV[0] or die qq($!);
local $/ = qq(\\0);
my @ff = map {chomp; $_} qx(find . -type f -iname '*.map' -print0);
local $/ = qq(\\n);
# CSV spec
# - record separator is CRLF
# - field separator is comma
# - every field is quoted
# - text encoding is UTF-8
local $\\ = qq(\\015\\012); # CRLF
local $, = qq(,); # COMMA
# print column header row
my @dd = ('column 1', 'column 2', 'column 3', 'column 4', 'column 5', 'column 6');
print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
# print data row per each file
while (@ff) {
my $f = shift @ff; # file path
if ( ! open(IN, '<', $f) ) {
warn qq(Failed to open $f: $!);
next;
$f =~ s%^.*/%%og; # file name
@dd = ('', $f, '', '', '', '');
while (<IN>) {
chomp;
$dd[0] = \"$2/$1/$3\" if m%Link Time\\s+=\\s+([0-9]{2})/([0-9]{2})/([0-9]{4})%o;
($dd[2] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of CODE\\s/o;
($dd[3] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of DATA\\s/o;
($dd[4] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of XDATA\\s/o;
($dd[5] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of FARCODE\\s/o;
last unless grep { /^$/ } @dd;
close IN;
print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
EOF
Hope this may help,
H -
How to read a tab seperated data from a text file using utl_file
Hi,
How to read a tab seperated data from a text file using utl_file...
I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....
Thanks in advance...
NaveenNaveen Nishad wrote:
How to read a tab seperated data from a text file using utl_file...
I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....If it's a text file then UTL_FILE will only allow you to read it a line at a time. It is then up to you to split that string up (search for split string on this forum for methods) into it's individual components.
If the text file contains a standard structure on each line, i.e. it is a fixed delimited structure, then you could use external tables to read the data instead. -
How to do import data from the text file into the mathscript window?
Could anyone tell me how to do import data from text file into mathscript window for labview 8?
MathScript Window openned, File, Load Data - it has options: custom pattern (*.mlv) or all files.
ThanksHi Milan,
Prior to loading data in Mathscript Window , you have to save the data from the Mathscript window (the default extension of the file is .mlv but you can choose any extension). This means that you cannot load data from a text file that was not created using the Mathscript window.
Please let me know if you have any further questions regarding this issue.
Regards,
Ankita -
Need to read data from a text file
I need to read data from a text file and create my own hash table out of it. I'm not allowed to use the built in Java class, so how would I go implementing my own reading method and hash table class?
It's not possible to read from a file without using classes from the core API*. You'll have to get clarification from your instructor as to which classes are and are not allowed.
[http://java.sun.com/docs/books/tutorial/essential/io/]
*Unless you write a bunch of JNI code to replicate what the java.io classes are doing. -
Error while loading data from a text file to a datastore
Hi all,
i am a starter in ODI. I am trying to load data from a text file into a datastore. I have put the file on a unix server whose location is defined in the topology manager. when i am trying to "view data" it is giving me error file does not exist at <location where i have put the file>. Please help meHi,
1. If your files are on a remote File System, you will need to copy one of your files to the machine ODI Designer is running on to allow ODI to retrieve the metadata information of the file.
2. In Topology create a Physical Schema, the directory you enter for Data and Work Schema should point at this local file.
3. Then define the File Datastore in ODI Designer. Enter a name, browse and select the file and fill in each filed of the Files tab.
* If its a Fixed file, click on the grid icon on the Columns tab to enter the columns and have Automatic Adjustment checked.
* If its a Delimited file, use the Reverse button on the Columns tab to reverse the columns.
* Right click on the File Datastore select View Data, if you can view data, that means the File Datastore has been defined correctly.
* If not, check each tab of the File Datastore to make sure everything is defined correctly and retry.
4. Once View Data is successful, you now change the directories (Data and Work Schema in Topology) to point at the remote File System. These directories must be accessible to the ODI Agent that will be used to run the transformations. The directory can be an absolute path (m:/public/data/files) or relative to the ODI Agent startup directory (../demo/files). It is strongly advised to use a UNC (independent from the execution location) for the path. When running the transformations with "no agent", the directory is relative to the directory where Oracle Data Integrator has been installed.
You need to have a agent process running at the system where your source file resides .
Then while running the odi interface choose that agent .
Thanks,
Sutirtha -
Can I use Visual Basic to covert form user data from multiple .pdf files to a single .csv file? If so, how?
You can automate Acrobat using IAC (InterApplication Communications), as documented in the Acrobat SDK. Your program could loop through a collection of PDFs, load them in Acrobat, extract the form data from each, and generate a CSV file that contains the data.
Acrobat can also do this with its "Merge Data Files into Spreadsheet" function, but this is a manual process.
Maybe you are looking for
-
Time Machine is causing my external hard drive not to be recognized or read
I have been using Time Machine on my MAC. I don't like it. I now have gone into preferences and stopped it from further backups. Now, I want to restore my Toshiba External Hard Drive and have it backup. When I look into my Macintosh HD, it does not "
-
I have noticed in 11.5 that the option to align a group of objects by the page margins while keeping the objects relative to each other is gone. Please tell me this option is just hidden somewhere and is still available! Blanchard
-
I cropped the photo to 16x20. With this crop I ended up with some transparent pixels on the right and left edges. I used the Trim tool to remove the transparent pixels. Question - after removing the transparent pixels with the Trim tool do I still ha
-
Top sites and video problems with Safari 4.0 and Snow Leopard
Since installing Snow Leopard, I've had problems with Safari 4.0. My Top Sites page doesn't load anymore, I get a blank white page. Also, video tutorials from Apple's own site will not display the video. I hear the audio portion but do not get video.
-
Keyboard shortcuts error - please re-install Photoshp CC
When loading up Photoshop CC I get an error message which says something like "unable to locate keyboard shortcuts, please re-install Photoshop CC. How can I do this?