Automatically read next file in folder

HI I am trying to read in files and use the attached vi to calculate the area under the curve.  everything works, except that I would like the functionality of being able to automatically select the "next file" or the "previous file" with out having to reopen user dialogue.  Any help would greatly be appreciated. 
Solved!
Go to Solution.
Attachments:
Integrate data ___ read next file WIP.vi ‏99 KB

I don't see where you determine what the first file is to be processed.
You have various indicators called name, appended path, and stripped path.  You seem to be jumping back and forth on creating paths, but I don't see where you initially determine what is the file.  I think you have problems with misuse of local variables that lead to race conditions where you don't know what is the value in the local variable because it is and when a data value was last written to the indicator.  This really manifests itself in the file name scheme.  You have a local variable of appended path that determines the stripped path and name and puts them into the indicator terminals.  But simulataneously, you are using local variables of stripped path and name to determine the value to put in the appended path indicator terminal.
I think you have a lot of the correct elements in there.  List Folder is going to give you the list of files in the folder.  I don't know how you determine what Next file is vs. Previous file.  Do you want it to be alphabetical, by file date, or just whatever order that the operating system returns the files?
Once you have an array of files (from list folder) then using the integer wire to determine which of the elements you want to use is correct.  But you aren't quite doing that.  You are taking the Name local variable, turning that string into an array (which will have exactly one element) and using the index of element (again a local variable) to either return that name back again, or an empty string in the event that the index element is greater than zero.
Overall, you have a lot of things happening in parallel when they are really sequential processes.  As a result, you are using local variables to pass data back and forth between your two case structures, but there is no control over whether the data is fresh from that loop iteration, or stale from the previous loop iteration.
Set up a flowchart as to what the sequence of steps would be and program to that.  You may want to look into event structures to handle button presses for next file, previous file, and read data, so that it executes the reading and analyzing of the files, and also updates the file index either 1 higher or lower when those buttons are pressed.

Similar Messages

  • [Urgent] How to let FileAdapter to read next file after a customized period

    Dear friends,
    We are using SOA Suite 11.1.1.5 and use FileAdapter in BPEL Process to read files.
    The file adapter in BPEL Process need to handle 14 inbound different files every batch time. And we want to let File Adapter to start reading next file after every 5 minutes. How can we achive this?
    We tried the MinimumAge and SingleThreadModel properties, but seems no use.
    Thank you in advance.
    Regards,
    Tony

    Hi Tony,
    I think this can help you. Set the following JCA property in File/FTP Adapter .jca file. This will restrict the max no. of files to be read every polling cycle. Set the polling frequency to 5 mins.
           <property name="MaxRaiseSize" value="1"/>Let me know if any problems.
    Regards,
    Neeraj Sehgal

  • Read contineously file from folder

    HI
    I have 1000 of files and I want read files from folder automatic. Each file ends with
    if $BATCH_FILE==true
    define $END,false
    else
    power off
    define $END,true
    if 1 text file is finish then it should load another file automatically

    Hi kalu,
    don't know what you're trying to do:
    - you have a "path" control but you don't use it for ListFolder...
    - you get an array of filenames from ListFolder, but you don't use that data later on...
    - you are using "OpenFile"/CloseFile to get a file path (in the event) and later on you use that path to read data from...
    Your original question doesn't has anything in common with those things you do now...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Read All files in folder and sub folder

    Hi,
    i can read files in a folder,but not in a sub folders.can any one give me idea to read all files in the folder and its sub folder.
    Deepan

    Hi
    This code may help you
    Bliz
    import java.io.File;
    import java.io.IOException;
    import java.io.RandomAccessFile;
    import java.nio.channels.FileChannel;
    public class CountFiles {
          * @param args
          * @throws IOException
          * Count files in <path> and all its subDirs
         public static String path = "c:";
         public static String src1 = "";
         public static FileChannel channel;
         public static int numF;
         public static int numD;
         public static void main(String[] args) throws IOException {
              countFiles(path);
              System.out.println("Number of files :\t"+numF);
              System.out.println("Number of dirs :\t"+numD);
         public static void countFiles(String strPath) throws IOException
              File src = new File(strPath);
              if (src.isDirectory())
                   numD++;
                   String list[] = src.list();
                   try {
                       for (int i = 0; i < list.length; i++)
                        src1 = src.getAbsolutePath() + "\\" + list;
                        File file = new File(src1);
                        try {
                   channel = new RandomAccessFile(file, "r").getChannel();
                        }catch(java.io.FileNotFoundException e){}
                        countFiles(src1);
                   }catch(java.lang.NullPointerException e){}
              else
              numF++;

  • Read a file from folder

    i need to get a file from application server folder with date validation.
    how do i get the file from foder with fname, size and date.

    Hi,
    Please try this.
        DATA: FILETAB TYPE TABLE OF FILE_INFO,
              FILEREC TYPE FILE_INFO,
              COUNT TYPE i,
              FZISE TYPE i.
        CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
          EXPORTING
            DIRECTORY                   = '<Yourfilename>'
            FILTER                      = ''
            FILES_ONLY                  = 'X'
          CHANGING
            FILE_TABLE                  = FILETAB
            COUNT                       = COUNT
          EXCEPTIONS
            CNTL_ERROR                  = 1
            DIRECTORY_LIST_FILES_FAILED = 2
            WRONG_PARAMETER             = 3
            ERROR_NO_GUI                = 4
            others                      = 5.
        IF SY-SUBRC <> 0.
          RAISE CNTL_ERROR.
        ENDIF.
        IF COUNT = 0.
    *     Does not exist
          RESULT = ABAP_FALSE.
          FSIZE  = 0.
        ELSE.
    *     Does exist
          RESULT = ABAP_TRUE.
          READ FILETAB INDEX 1 INTO FILEREC.
          FSIZE = FILEREC-FILELENGTH.
        ENDIF.
    Regards,
    Ferry Lianto

  • Reading All Files inside folder codeBase, Applet!

    I have an applet, placed in a Jar file.. everything is ok,,
    I have a resource folder outside the Jar, which has some files.
    how can I read what is inside the resource folder, which is located outisde the Jar, without having their addresses before hand!!
    in short, I would like the applet to open the resource folder, get an array of all files in the folder, and then reads them.
    I tried encapsulating the getCodeBase().toURI() with a File Object.
    But when I call the file.list() it throws an AccessControlException
    thank you.

    Here is a simple example of using ftp to obtain file list using Jakarta common net package.
    // ftp - related imports
    import org.apache.commons.net.ftp.FTPClient;
    import org.apache.commons.net.ftp.FTPReply;
    // main method
              FTPClient ftpClient = null;
              try {
                   ftpClient = new FTPClient();
                   ftpClient.connect("REMOTE_HOST", "remote port, use 21 in common case");
                   System.out.print(ftpClient.getReplyString());
                   int reply = ftpClient.getReplyCode();
                   if(!FTPReply.isPositiveCompletion(reply)) {
              ftpClient.disconnect();
              System.err.println("FTP server refused connection.");
              System.exit(1);
                   boolean isLoggedIn = ftpClient.login("your login", "your pass");
                   ftpClient.changeWorkingDirectory("/your remote dir/");
                   String[] fNames = ftpClient.listNames();
                   for (int i = 0; i < fNames.length; i++) {
                        System.out.println(fNames);
                   ftpClient.logout();
              } catch (IOException e) {
                   e.printStackTrace();
              } finally {
                   if(ftpClient.isConnected()) {
                        try {
                             ftpClient.disconnect();
                        } catch(IOException ioe) {
                             ioe.printStackTrace();
    System.exit(0);

  • Reading all files froma  folder

    Hi ,
    Does anyone know how to read the data from all text files in a given folder?
    I mean does text_io recongnises a certain sintax to do this?
    Thanks,
    Sandu

    Well
    I'm having problems initializing a java.lang.String as ora_java.jobject.
    I was able to import in forms my class ,(wich works ok when tested like standalone java class,it returns all the filenames from a folder),a package was generated on the form for it.
    But,I've got to pass it the folder name as a String.
    I've imported java.lang.String as ora_java.jobject,and a package was generated on the form.
    When I try to call string.new('c:\work');
    it won't compile,it says invalid reference to variable String.
    What should I do?Is there any predefined Type in ora_java package for java.lang.String?
    Thanks,
    Sandu

  • Read XML file in folder /src/mime...

    Hello,
    I got a XML file with some data which I need for my application. I put the file in the folder: src/mime/components/com.sap.test/mydata.xml
    I also tried src/packages/com/sap/test/mydata.xml
    How can I access this file?
    e.g. I tried
    InputStream is = getClass().getClassLoader().getResourceAsStream("mydata.xml");
    Thanks
    Rene

    HI Rene,
    Let the xml file be mydata.xml inside src/mime/components/com.sap.test/
    To access to this file,
    String url=WDURLGenerator.getResourcePath(wdComponentAPI.getComponent().getDeployableObjectPart(),"mydata.xml");
    File f=new File(url);
    try
    FileInputStream fos=new FileInputStream(url);
    catch (Exception e)
    wdComponentAPI.getMessageManager().reportException("While reading file "+e,true);
    Regards,
    Fahad Hamsa

  • Need help, reading next file line

    i have a file that i am reading using this code, this code reads only string on the first line
    i wnat it to read the second line from the file when the method is called again
    private transactionLine="";
    public void fileReading()
    try
              try
                   FileInputStream finstr = new FileInputStream(userFile);          
              BufferedInputStream bfinstr = new BufferedInputStream(finstr);
              DataInputStream dainsstr = new DataInputStream(bfinstr);
                             transactionLine = dainsstr.readLine();     //holds the transaction line
                             System.out.println(transactionLine);
              catch(FileNotFoundException fnf)
                   System.out.println("File not found");
                   userFile=userInput();
                   fileReading();
                   catch(IOException ioe)
                        System.out.println("io exception at point 1");//point 1

    How big is your file ?
    If it's small file, you can just create a static counter that reads the lines (again and again).
    Else if its a little bigger file, you might want to put it in a vector (once read, always there).
    If its a very large file, then you might work with RandomAccessFile, and you'll have to know how the file is structered.
    ReadFile and ReadFile2 are 2 examples of read the lines, or place in vector.
    good luck!
    import java.io.*;
    public class ReadFile
        private File file = null;
        private static int executed = 0;
        public ReadFile(String fileName)
            //find the file
            File f = new File(fileName);
            if( !f.exists() )
                System.out.println("Cannot find the specified file ( " + fileName + ").");
            else
                this.file = f;
        public String getTransactionLine()
            executed++;
            String line = "";
            if( this.file == null || executed < 1 )
                return line;
            try
                //create a reader
                BufferedReader br = new BufferedReader( new FileReader(file) );
                int counter = 1;
                //read the lines depends on time it been executed
                while( (line=br.readLine())!=null )
                    if( counter++ == executed )
                        break;
                //if exceeded the amount of lines in the file
                if( executed >= counter )
                    line = "Could not read more, the file contains only " + (counter-1) + " lines.";
            catch (Exception ex)
                ex.printStackTrace();
            return line;
        public static void main(String[] args)
            ReadFile rf = new ReadFile("c:\\debugLog.txt");
            //read 1
            String transactionLine = rf.getTransactionLine();
            //output:
            System.out.println(transactionLine);
            //read 2
            transactionLine = rf.getTransactionLine();
            //output:
            System.out.println(transactionLine);
            //read 3
            transactionLine = rf.getTransactionLine();
            //output:
            System.out.println(transactionLine);
            //read 4
            transactionLine = rf.getTransactionLine();
            //output:
            System.out.println(transactionLine);
            //read 5
            transactionLine = rf.getTransactionLine();
            //output:
            System.out.println(transactionLine);
    import java.io.*;
    import java.util.Vector;
    public class ReadFile2
        private static int executed = 0;
        private Vector lines = null;
        public ReadFile2(String fileName)
            //find the file
            File file = new File(fileName);
            if( !file.exists() )
                System.out.println("Cannot find the specified file ( " + fileName + ").");
                return;
            //this vector will contain all lines.
            lines = new Vector();
            try
                //create a reader
                BufferedReader br = new BufferedReader( new FileReader(file) );
                String line = "";
                //read the lines and add them to a vector (lines).
                while( (line=br.readLine())!=null )
                    lines.add(line);
            catch (Exception ex)
                ex.printStackTrace();
        public String getTransactionLine()
            String line = "";
            try
                line = (String) lines.get(executed++);
            catch( Exception ex )
                line = "Could not read more, the file contains only " + (executed-1) + " lines.";
            return line;
        public static void main(String[] args)
            ReadFile2 rf = new ReadFile2("c:\\debugLog.txt");
            //read 1
            String transactionLine = rf.getTransactionLine();
            //output:
            System.out.println(transactionLine);
            //read 2
            transactionLine = rf.getTransactionLine();
            //output:
            System.out.println(transactionLine);
            //read 3
            transactionLine = rf.getTransactionLine();
            //output:
            System.out.println(transactionLine);
            //read 4
            transactionLine = rf.getTransactionLine();
            //output:
            System.out.println(transactionLine);
            //read 5
            transactionLine = rf.getTransactionLine();
            //output:
            System.out.println(transactionLine);
    }

  • Reading files from folder in java

    Hi ..I am new to java ..can you help me ..how to read the files from folder(containing 10 java files) and store in a array..
    Thanks

    use the java.io package, more specifically java.io.File. You can construct a new File by passing in a String version of the pathname, and then store that into your array.

  • Desktop oddities when trashing file or folder

    Okay, this isn't a big deal, but it disturbs my normal way of using the computer.
    When I press Command-Delete for a file or folder I've selected on the Desktop it moves it to the trash.
    However THEN the Finder selects the "next" file or folder on the Desktop?
    Why? This is stupid.
    {I upgraded from SL to ML, so maybe I missed something}

    Okay, I created a dummy account called dummy and switched to that. As clean of an account as it could be, since the fun of signing up for an iCloud account/Apple ID appeared. Still did it. Signed back into my regular account, still doing it. I do have a number of files/folders on my Desktop, but not like some crazy people, and I have an alias for the harddrive there too.What I've noticed is that the sequence almost makes sense... so, I select a file, press Command-Delete, that file moves to the trash, and another file that was the most recent one created on the desktop is the next selected. Weird, huh? I think it's just a matter of playing with the "Sort By" and "Clean Up By" options unde View, but it's still bugging me since I have to deselect a file/folder after trashing a previous one.
    Meh, still no big deal.

  • Read a file content and copy to another Diectory

    I wanted to do the following
    1-read a file from dir
    2- read the content of the file
    3- if the file contains zeros
    exit from this file and go to read next file
    else
    do some calculations
    i read a file and its contents and found zeros in the contents, so how can i say in the code to go to next file..
    any help please

    It depends on your code, but most likely using "return":
    //pseudo code
    while(moreFiles) {
      parseFile(file)
    void parseFile(File file) {
      while(moreContentToRead) {
        if(foundZero) {
          return;
    }

  • Reading multiples files from a folder and processing

    Hello everyone,
    Im working on a project to analyst and process Acoustic Emission Signals. My problem is that I have a folder that containts several files .txt. Every file contains 16 waveforms (16 channels) that I need to process with an equation to detect the arrival times of the waves.
    I have been working in this way : Running the labview code that open the file that I select .. then the processing happens on every wave and I click stop to select the file where I want to save the solutions. The solutions is only a vector of the 16 arrival times detected. Then I have to stop the code (by clicking Abort Execution) and repeat the process ... Run the code and bla bla bla .. and save on the same solution file that I used before.
    The ideal situation is to read the files whitout stoping the execution of the code .. For example clicking a buttom to pass to the next file and saving all the solutions to the same file. That is beacause sometimes Im going to have more than a 100 files and this will give me a hard time if a forget in which file I was working. The idea is to make an automatic process.
    Please .. I have been trying to find a solution to this while Im working in other part of the code. If someone could suggest me a solution it would be great.
    Thanks.

    Hello everyone,
    Well Im sorry if I didn't post my .vi ... I was working on it ... and I found a solution (whit some help that I found on the forums) but Im not happy at all ... because I still have to give the last part of the file name.
    For example at the beginning I have to input the file name without the final number of the event ...
    C:\Users\Irish\Desktop\Hydraulic Fracturing\E1_evento
    then I finish adding the file number that I want to process on the folder
    C:\Users\Irish\Desktop\Hydraulic Fracturing\E1_evento2.txt or 9.text or ... just the number ...
    This is the case when I want to process every file specifying the file .. but what could you suggest me to do process all the data file by file ?
    I attached the part of the code that Im using for this specific problem ...
    Im using Labview 8.5
    Thanks ...
    Message Edited by Alvaro_Ortiz on 08-26-2009 03:14 PM
    Attachments:
    MultReadFiles.vi ‏58 KB

  • Reading in files from a folder

    Hiya, i have a folder of .txt files i want to read in, i can read it single txt files when i specify the name of it, but i want to be able to automatically read ALL text files within a folder, so read one in, perform some processing on it, then move to the next one, till all present folders have passed through. is this possible?
    thanks
    dori

    Try this. This is probably what you want:
    import java.util.*;
    import java.io.*;
    public class Test
      public static void main (String args []) throws Exception
         File dir = new File ("c:\");
         readFiles (dir);
      public static void readFiles (File file)
         if (file.isDirectory ())
              String [] exts = {".txt"};
              FileNameFilter fileNameFilter = new FileNameFilter (exts);
              File [] children = file.listFiles (fileNameFilter);
              for (int i=0;i < children.length;i++)
                   readFiles (children );
         else
              // Process the file here
              System.out.println ("Processing File : " + file.getPath ());
         static class FileNameFilter implements FilenameFilter
              private String [] extensions = null;
              public FileNameFilter (String [] exts)
                   extensions = exts;
              public boolean accept (File dir, String name)
                   File tmpFile = new File (dir.getPath () + "/" + name);
                   if (tmpFile.isDirectory ()) return true;
                   if (extensions == null) return false;
                   name = name.toLowerCase ();
                   for (int i=0;i < extensions.length;i++)
                        if (name.endsWith (extensions [i])) return true;
                        //if (name.endsWith (".jpg")) return true;
                   return false;

  • How to Read all files inside resource Folder inside Jar?

    I have a Jar file,,,, The program reads for resource files in the resource folder inside the Jar. I want my program to read all files inside this folder without knowing the names or the number of files in the folder.
    I am using this to make an Applet easy to be updated with spicific files. I just want to add a file inside the resource folder and Jar the program and automatically the program reads what ever is in there!!
    I used the File class to get all file names inside the resource folder. it works fine before Jarring the program. After I jar I recieve a URI not Herarichy Exception!!
    File fold=new java.io.File(getClass().getResource(folder).toURI());
    String[] files=fold.list();
    I hope the question is clear!!

    How to get the directory and jar file that you class resides in:
    // returns path and jarfile (ex: /home/mydir/my.jar)
    public String getJarfileName()
            // Get the location of the jar file and the jar file name
            java.net.URL outputURL = YourClass.class.getProtectionDomain().getCodeSource().getLocation();
            String outputString = outputURL.toString();
            String[] parseString;
            int index1 = outputString.indexOf(":");
            int index2 = outputString.lastIndexOf(":");
            if (index1!=index2) // Windows/DOS uses C: naming convention
               parseString = outputString.split("file:/");
            else
               parseString = outputString.split("file:");
            String jarFilename = parseString[1];
           return jarFilename;
    }If your my.jar was in /home/mydir, it will store "/home/mydir/my.jar" in jarFilename.
    note: getLocation returns "file:/C:/home/mydir/my.jar" for Windows/DOS and "file:/home/mydir/my.jar" for windows, thus why I look for the first and last index of the colon so I can correctly split the string.
    If you want to grab a file in the jar file and get an InputStream, do the following:
    import java.io.*;
    import java.util.Enumeration;
    // jar stuff
    import java.util.jar.*;
    import java.util.zip.ZipEntry;
    public class Jaris
       private JarFile jf;
       public Jaris(String jarFilename) throws Exception
           try
                           jf = new JarFile(jarFilename);
           catch (Exception e)
                jf=null;
                throw(e);
       public InputStream getInputStream(String matchString) throws Exception
           ZipEntry ze=null;
           try
              Enumeration resources = jf.entries();
              while ( resources.hasMoreElements() )
                 JarEntry je = (JarEntry) resources.nextElement();
                 // find a file that matches this string from anywhere in my jar file
                 if ( je.getName().matches(".*\\"+matchString) )
                    String filename=je.getName();
                    ze=jf.getEntry(filename);
          catch (Exception e)
             throw(e);
          InputStream is = jf.getInputStream(ze);
          return is;
       // for testing the Jaris methods
       public static void main(String[] args)
          try
               String jarFilename=getJarfileName();
               Jaris jis = new Jaris(jarFilename); // this is the string we got from the other method listed above
               InputStream is=jis.getInputStream("myfile.txt"); // can be used for xml, xsl, etc
          catch (Exception e)
             // this is just a test, so we'll ignore the exception
    }Happy coding! :)
    Doc

Maybe you are looking for

  • Ipod not recognized in windows vista nor in itunes

    İ need help. İ have tried the 5 r's. Since neither my computer nor itunes will recognize my ipod*, İ can not complete the restore. İ have downloaded the update from vista, still to no avail. İ don't know what else to do. since one definition of insan

  • Will not update!

    whenever i plug my ipod nano in a message comes up on itunes saying "songs on the ipod 'janes ipod' cannot be updated because all of the playlists selected for updating no longer exsist" what can i do? thanx xxx

  • Coverflow does not appear

    I have a classic 80Gb iPod and want to use coverflow. However, it doesn't even appear in the "music" menu, or anywhere else. Any suggestions on what I need to do to get it activated? I have the most up to date software for the iPod, updated yesterday

  • How can I get iMovie 2011 to recognize my Canon Vixia HV30?

    When trying to import videos in iMovie 2011, my iMac doesn't recognize my camcorder - it just pulls up the built in camera on the iMac

  • Use of client nat pools on the CSM

    Hi Guys, Just a quick questions about the use of NAT POOLS, which the configuration guide is a little scant for information. If a client NAT pool such as this is used (16 addresses): natpool POOL1 10.1.5.0 10.1.5.15 netmask 255.255.255.240 I just wan