How to read from 2 data files ?

Hi,
I'm trying to create a program that will read data from two dat files that are linked by a reference code in each file.
I have been using StringTokenizer to read from one file as follows:
but the problem is that the dat files contain int, String and double values.
import java.io.*;
import java.util.StringTokenizer;
public class Student
     public static void main(String[]args)
     String file = "CourseWork.dat";//Locate the file to open
     String input;     // to be used to identify each line of text
     String word;     // used to identify each word in the text
     StringTokenizer tokenizer;//value of StringTokenizer
     BufferedReader fin = Text.open(file);
     input = fin.readLine;          
     while (input !=null)          
               tokenizer = new StringTokenizer (input);
               while (tokenizer.hasMoreTokens())                {                                                                                               word = tokenizer.nextToken();
               System.out.println(input);
               input = fin.readLine();
Any pointers greatly appreciated

read all of them to a StringBuffer,
then stoken.
peter
Pivotonic Inc. http://www.pivotonic.com
1. java IDE tool : JawaBeginer
2. java jar tool : JavaJar
-----------------------------

Similar Messages

  • How to read from properties file

    Hi,
    I am using JSR 168.
    while creating a new portlet, a folder gets created with the name as "portlet". Under which is resource package and <PortletName>Bundle.java.
    pls tell me how to read from .properties file.
    waiting eagerly for some reply
    Thanks & Regards,
    HP
    Edited by: user9003827 on Apr 13, 2010 3:42 AM

    I think i have mixed it up :)
    I have looked at it again and believe you are using regular JSP portlets.
    Can you tell what you want to achieve by reading .properties file. Are you meaning the preferences of the portlet or what exactly are you trying to do?
    Reading propertie files is easy:
    // Read properties file.
    Properties properties = new Properties();
    try {
        properties.load(new FileInputStream("filename.properties"));
        String myKey = properties.getProperty("yourKey");
    } catch (IOException e) {
    }Edited by: Yannick.O on 13-Apr-2010 05:52

  • How to read from a file line by line

    Hi
    I am new to using LabView and was wondering how I could read data from a text file one line at a time and display this data one line at a time as well. I tried looking through the Reading from Text File . vi example but that just seems to be reading and displaying everything together.
    Thanks
    -Karan

    Hi
    My aim is to read text line by line and to then go ahead and display the last 8 reaad lines of code to give the impression of text falling down a screen. I tested the first while loop and that seemed to work fine. However, when I encounter an EOF, I would like the text already read to keep making its way down the screen and keep inputting NULL characters into the array to simulate the effect of the text falling down the screen which is why I created the second while loop. I tried to input the NULL characters using a box for ENUM constants. However, I kept getting an error saying the data types do not match. What would I need to do? For the display I plan on putting indicators next to the 8 places where the text would be stored which I have not done so far.
    I am also attaching a copy of the error.
    Thanks
    -Karan
    Attachments:
    DisplayText.vi ‏40 KB
    Error.JPG ‏89 KB
    PictureOfBlock.JPG ‏120 KB

  • How to read from text file?

    I would like to read data (frequencies) already written in a text file. I will need read these frequencies one at a time to set the function generator (as part of my data acquisition application), acquire data that is in turn written to a file and then go back and read the next frequency from the file to repeat the process again. I also have another idea of doing the same, which is read all the frequencies from the text file and populate a table and a frequency value is picked from the table each time to go through the process mentioned above.
    Can anyone suggest the following: (1) How to read from a text file, (2) What could be the most efficient way of solving my above problem.
    I am a new LabVIEW user and any help will be appreciated.

    Hi Research,
    Depending on the format of the data file, there are a few options for reading it.  If it is tab delimited, you may want to use the Read from SpreadSheet File VI which will read the file into an Array.  You can then use the Index Array VI to pull out individual entries.  If the files is ASCII but not tab delimited, you could use the regular Open File and Read File VIs.  You can either read the file out piece by piece, or read the entire file into a string and then use the Match Pattern VI to parse out the different elements (there are actually many ways to do this - check out the Strings subpalette). 
    Since you're new to LabVIEW, you may want to check out these resources:
    Three Hour Introduction to LabVIEW
    Six Hour Introduction to LabVIEW
    Getting Started with LabVIEW
    I hope this helps!  Let us know if you have more questions,
    Megan B.
    National Instruments

  • How to read multiple dat files.

    Hello Everyone!
    I am working on a project that requires one file that creates a JFrame with a current file title, JTextFields that accesses two .dat files and a JButton.
    The user clicks a JButton to cycle through the first sequential .dat file. When the end of the first file is reached the file is closed, the JFrame title is changed to the second file title as the user continues to click the JButton to continue on viewing the second file?s records, until the second reaches the end of file.
    The project requires using Try-Catches to catch the EOF exceptions and IOExceptions and Thread or Runnable.
    I have been able to get one file to read and display its records; however, researching back through my text on how to read/write to files I haven?t been able to determine how to get to the end of the file and proceed to the next file without triggering the EOFException. I have even tried multiple Try-Catches (one for each file within the actionPerformed method) and that ends up ignoring the first file records and only displays the second files records.
    This is a school project and we have only covered just the bare basics of Java over the last two months. So, any hints that anyone can provide can only be of what type of procedure will be needed or what procedure won?t help to complete the task, without giving away the solution.
    I have spent approximately 40 hours of study time on this project and believe that I have definitely run into a major snag.
    The following is the code I have so far:
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class StudentRead extends JFrame implements ActionListener
       private JLabel gradStudentList = new JLabel("GRADUATE Student List");
       private JLabel undergradStudentList = new JLabel("UNDERGRADUATE Student List"); 
       private Font bigFont = new Font("Helvetica", Font.ITALIC, 24);
       private JLabel userprompt = new JLabel("View the students");
       private JTextField idNumText = new JTextField(4); 
       private JTextField lastNameText = new JTextField(15);
       private JTextField firstNameText = new JTextField(15);
       private JButton viewRecordButton = new JButton("View Record");
       private JLabel idNumberLabel = new JLabel("ID Number"); 
       private JLabel lastNameLabel = new JLabel("Last name"); 
       private JLabel firstNameLabel = new JLabel("First name");
       private Container con = getContentPane();
       DataInputStream gradStudentInStream;
       DataInputStream undergradStudentInStream;
       public StudentRead()
          super("Read Student Records");
          try
             gradStudentInStream = new DataInputStream(new FileInputStream("GradStudents.dat"));
             undergradStudentInStream = new DataInputStream(new FileInputStream("UndergradStudents.dat"));
          catch(IOException e)
             System.err.println("File not opened");
             System.exit(1);
          setSize(325, 200);
          con.setLayout(new FlowLayout());
          gradStudentList.setFont(bigFont);
          con.add(gradStudentList);
          con.add(userprompt);
          con.add(idNumberLabel);
          con.add(idNumText);
          con.add(lastNameLabel);
          con.add(lastNameText);
          con.add(firstNameLabel);
          con.add(firstNameText);
          con.add(viewRecordButton);
          viewRecordButton.addActionListener(this);
          setVisible(true);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       public void actionPerformed(ActionEvent e1)
          String lastName, firstName;     
          int IdNum;
          try
             IdNum = gradStudentInStream.readInt();      
             lastName = gradStudentInStream.readUTF();
             firstName = gradStudentInStream.readUTF();
             idNumText.setText(String.valueOf(IdNum));
             lastNameText.setText(lastName);
             firstNameText.setText(firstName);
          catch(EOFException e2)
             closeFile();
             System.exit(0);
          catch(IOException e3)
             System.err.println("Error reading file");
             System.out.println("out");      
             System.exit(1);
       public void closeFile()
          try
             gradStudentInStream.close();
             System.exit(0);
          catch(IOException e)
             System.err.println("Error closing file");
             System.exit(1);
       public static void main(String[] args)
          StudentRead rsr = new StudentRead();
    }

    deepak_1your.com wrote:
    hi,
    If you want to read a file guarding yourself agianst exceptions....
    check this article.... the code presented in this article might suit your needs...
    [http://1your.com/fusion/infusions/articles/readarticle.php?article_id=17|http://1your.com/fusion/infusions/articles/readarticle.php?article_id=17]
    And how does that help with a DataInputStream?

  • Problem with reading from DAT file. FileNotFound exception

    Can't seem to find the issue here. Two files, one (listOfHockeyPlayers) reads from a DAT file a list of players. The other (HockeyPlayer) has just the constructor to make a new hockey player from the read data.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.util.*;
    import java.awt.*;
    import java.io.*;
    public class ImportHockeyPlayers
    private ArrayList<HockeyPlayer> listOfHockeyPlayers = new ArrayList<HockeyPlayer>();
    public ImportHockeyPlayers(String fileName)
      throws FileNotFoundException
      try
       Scanner scan = new Scanner(new File(fileName));
       while (scan.hasNext())
        //Uses all the parameters from the HockeyPlayer constructor
        String firstName = scan.next();
        String lastName = scan.next();
        int num = scan.nextInt();
        String country = scan.next();
        int dob = scan.nextInt();
        String hand = scan.next();
        int playerGoals = scan.nextInt();
        int playerAssists = scan.nextInt();
        int playerPoints = playerGoals + playerAssists;
        //listOfHockeyPlayers.add(new HockeyPlayer(scan.next(),scan.next(),scan.nextInt(),scan.next(),scan.nextInt(),scan.next(),
         //scan.nextInt(),scan.nextInt(),scan.nextInt()));
      catch(FileNotFoundException e)
       throw new FileNotFoundException("File Not Found!");
    public String toString()
      String s = "";
      for(int i = 0; i < listOfHockeyPlayers.size(); i++)
       s += listOfHockeyPlayers.get(i);
      return s;
    public class HockeyPlayer
    private String playerFirstName;
    private String playerLastName;
    private int playerNum;
    private String playerCountry;
    private int playerDOB;
    private String playerHanded;
    private int playerGoals;
    private int playerAssists;
    private int playerPoints;
    public HockeyPlayer(String firstName, String lastName, int num, String country, int DOB,
      String hand, int goals, int assists, int points)
      this.playerFirstName = firstName;
      this.playerLastName = lastName;
      this.playerNum = num;
      this.playerCountry = country;
      this.playerDOB = DOB;
      this.playerHanded = hand;
      this.playerGoals = goals;
      this.playerAssists = assists;
      this.playerPoints = goals + assists;
    DAT File
    Wayne Gretzky 99 CAN 8/13/87 R 120 222
    Joe Sakic 19 CAN 9/30/77 L 123 210These are all in early development, we seem to have the idea down but keep getting the odd FileNotFound exception when making an object of the ImportHockeyPlayers class with the parameter of the DAT file.
    We might even be on the wrong track with an easier way to do this. To give you an idea of what we want to do...read from the file and be able to pretty much plug in al lthe players into a GUI with a list of the all the players.
    Thanks for your time.

    Thanks for the tip on the date format...good to
    know.
    public static void main(String[] args)
    GUI gui = new GUI();
    ImportHockeyPlayers ihp = new
    ImportHockeyPlayers("HockeyPlayers.dat");
    }It's just being called in the main.
    Throws this error:
    GUI.java:39: unreported exception
    java.io.FileNotFoundException; must be caught or
    declared to be thrown
    ImportHockeyPlayers ihp = new
    ImportHockeyPlayers("HockeyPlayers.dat");
    ^This error is simply telling you that an exception may occur so you must enclose it in a try catch block or change the main method to throw the exception as follows
    public static void main(String[] args) throws  
                          java.io.FileNotFoundException {
         GUI gui = new GUI();
         ImportHockeyPlayers ihp = new
         ImportHockeyPlayers("HockeyPlayers.dat");
    }or
    public static void main(String[] args) {
         GUI gui = new GUI();
         try {
              ImportHockeyPlayers ihp = new
              ImportHockeyPlayers("HockeyPlayers.dat");
         catch (FileNotFoundException e) {
              System.out.println("error, file not found");
    }I would reccomend the second approch, it will be more helpful in debugging, also make sure that the capitalization of "HockeyPlayers.dat" is correct
    hope that helps

  • How to Read from a file UTL_FILE.

    I have created a file.
    Now i need to read it. I have used following code, but at the time of execution i am getting error, ORA-065-012, & ORA-29283.
    I am giving path as /oracle/PRD/dataload
    and file_name is as CREATE_FILE_TESTING.TXT
    the procedure is as -
    CREATE OR REPLACE PROCEDURE pms_generate_file
    path VARCHAR2,
    file_name VARCHAR2
    IS
    file_handle UTL_FILE.FILE_TYPE;
    v_text VARCHAR(4000);
    BEGIN
    file_handle := UTL_FILE.FOPEN(path, file_name, 'R');
    UTL_FILE.GET_LINE (file_handle, v_text);
    DBMS_OUTPUT.PUT_LINE(v_text);
    UTL_FILE.FCLOSE (file_handle);
    END;
    Regards,
    AgrawalV

    And you immediately used the Oracle documentation and found that
    ORAQ-29283 : invalid file operation
    Cause: An attempt was made to read from a file or directory that does not exist, or file or directory access was denied by the operating system.
    and resolved that issue first.
    What was the result of fixing the invalid file access issue? Or what have you attempted so far in resolving that issue?

  • How to  read from excel file and write it using implicit jsp out object

    our code is as below:Please give us proper solution.
    we are reading from Excel file and writing in dynamicaly generated Excel file.it is writing but not as original excel sheet.we are using response.setContentType and response.setHeader for generating pop up for saveing the original file in to dynamically generated Excel file.
    <%@ page contentType="application/vnd.ms-excel" %>
    <%     
         //String dLoadFile = (String)request.getParameter("jspname1");
         String dLoadFile = "c:/purge_trns_nav.xls" ;
         File f = new File(dLoadFile);
         //set the content type(can be excel/word/powerpoint etc..)
         response.setContentType ("application/msexcel");
         //get the file name
         String name = f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length());
         //set the header and also the Name by which user will be prompted to save
         response.setHeader ("Content-Disposition", "attachment;     filename="+name);
         //OPen an input stream to the file and post the file contents thru the
         //servlet output stream to the client m/c
              FileInputStream in = new FileInputStream(f);
              //ServletOutputStream outs = response.getOutputStream();
              int bit = 10;
              int i = 0;
              try {
                        while (bit >= 0) {
                        bit = in.read();
                        out.write(bit) ;
    } catch (IOException ioe) { ioe.printStackTrace(System.out); }
              out.flush();
    out.close();
    in.close();     
    %>

    If you want to copy files as fast as possible, without processing them (as the DOS "copy" or the Unix "cp" command), you can try the java.nio.channels package.
    import java.nio.*;
    import java.nio.channels.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    class Kopy {
         * @param args [0] = source filename
         *        args [1] = destination filename
        public static void main(String[] args) throws Exception {
            if (args.length != 2) {
                System.err.println ("Syntax: java -cp . Kopy source destination");
                System.exit(1);
            File in = new File(args[0]);
            long fileLength = in.length();
            long t = System.currentTimeMillis();
            FileInputStream fis = new FileInputStream (in);
            FileOutputStream fos = new FileOutputStream (args[1]);
            FileChannel fci = fis.getChannel();
            FileChannel fco = fos.getChannel();
            fco.transferFrom(fci, 0, fileLength);
            fis.close();
            fos.close();
            t = System.currentTimeMillis() - t;
            NumberFormat nf = new DecimalFormat("#,##0.00");
            System.out.print (nf.format(fileLength/1024.0) + "kB copied");
            if (t > 0) {
                System.out.println (" in " + t + "ms: " + nf.format(fileLength / 1.024 / t) + " kB/s");
    }

  • How to read the data file and write into the same file without a temp table

    Hi,
    I have a requirement as below:
    We are running lockbox process for several business, but for a few businesses we have requirement where in we receive a flat file in different format other than how the transmission format is defined.
    This is a 10.7 to 11.10 migration. In 10.7 the users are using a custom table into which they are first loading the raw data and writing a pl/sql validation on that and loading it into a new flat file and then running the lockbox process.
    But in 11.10 we want to restrict using temp table how can we achieve this.
    Can we read the file first and then do validations accordingly and then write to the same file and process the lockbox.
    Any inputs are highly appreciated.
    Thanks & Regards,
    Lakshmi Kalyan Vara Prasad.

    Hello Gurus,
    Let me tell you about my requirement clearly with an example.
    Problem:
    i am receiving a dat file from bank in below format
    105A371273020563007 07030415509174REF3178503 001367423860020015E129045
    in this detail 1 record starting from 38th character to next 15 characters is merchant reference number
    REF3178503 --- REF denotes it as Sales Order
    ACC denotes it as Customer No
    INV denotes it as Transaction Number
    based on this 15 characters......my validation comes.
    If i see REF i need to pick that complete record and then fill that record with the SO details as per my system and then submit the file for lockbox processing.
    In 10.7 they created a temporary table into which they are loading the data using a control file....once the data is loaded into the temporary table then they are doing a validation and updating the record exactly as required and then creating one another file and then submitting the file for lockbox processing.
    Where as in 11.10 they want to bypass these temporary tables and writing it into a different file.
    Can this be handled by writing a pl/sql procedure ??
    My findings:
    May be i am wrong.......but i think .......if we first get the data into ar_payments_interface_all table and then do the validations and then complete the lockbox process may help.
    Any suggestions from Oracle GURUS is highly appreciated.
    Thanks & Regards,
    Lakshmi Kalyan Vara Prasad.

  • How to read from txt file that has words in between?

    Hi all,
    I am using Labview 8.2.
    I would like to read from a text file.  I have data (after each time it is has averaged over 100 waveforms) repeatedly stored on to the file.  The idea is to further improve SNR in post processing by again averaging the data (that has been averaged over the 100 waveforms).  
    I can get LabView  to save the data repeatedly into the file, so it keeps getting appended.
    The problem is to read the data in labview so I can now again average it.  The problem is the labview seperates the sets of data with the following:
    " Channels    1    
    Samples    9925    
    Date    2008/10/28    
    Time    17:16:11.638363    
    X_Dimension    Time    
    X0    -3.0125000000000013E-3    
    Delta_X    2.500000E-6    
    ***End_of_Header***        "
    So When I read it, it only sees the first set of data.
    Can someone please tell me how to read all the sets of data in labview?
    I have attached the file I want to read "acquiredwaveform.txt"  and the basic VI (really basic btw) to read the file.
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    ReadFileAndAverage.vi ‏48 KB
    acquiredWaveform.txt ‏605 KB

    Thanks again DFGray for the comments. 
    After the correlations to find the peak positions, i just take the max value.  And you are right the accuracy is limited by the number of  samples per cycle.  Perhaps it would be clearer if you see the code.
    1) Basically I get a signal on the up and downslope of the sine wave.  On the down slope however the signal is negative, i.e. its is flipped.  So before I shift and average...I 'cut' the waveform into 4 (when cycles per buffer = 2, then I get 4 signals, 2 on the up slope and 2 on down slope) bits.  Counting from one, I flip the even number, cut it, and but an array of waveforms which is then sent to be convolved and shifted.
    2) Array of waveforms are stored to be phased shifted (Convolve and shift vi) and averaged (entire averaging vi which uses the convolve and shift vi as a sub vi). 
    * Phase shifting doesn't work when I cut and put it together (So something is wrong in cut waveform vi) 
    * Also if it isn't too time consuming could you give me an example of interpolating and shifting thing.
    * Also if you have any comments regarding the following VIs please let me know.  
    Thanks 
    Attached is:
    1) Cut waveform vi
    2) Convolve and shift
    3) Entire averaging 
    Attachments:
    SubVICutWaveforms.vi ‏37 KB
    SubVIConvolveShift.vi ‏30 KB
    SubVIEntireAveraging2.vi ‏43 KB

  • How to read a data file combining strings and data

    Hello,
    I'm having a data file combining strings and datas to read. I'm trying to read the filename, time, constants and comments into four seperate string indicators (the lines for the comments varies for different files). And read the data into a 2-D numeric array. How can I do this? Is there any function that can serch special characters in the spreadsheet file so I can exactly locate where I should start reading the specific data. The following is how the data file appears. Thank you very much.
    Best,
    Richard
    filename.dat
    14:59:00 12/31/2009
    Sample = 2451
    Frequency = 300, Wait time = 2500
    Temperature = 20
    some comments
    some comments
    some comments
    some comments
    some comments
    7.0000E+2    1.5810E-5
    7.0050E+2    1.5400E-5
    7.0100E+2    1.5500E-5
    7.0150E+2    1.5180E-5
    Message Edited by Richard1017 on 10-02-2009 03:10 PM
    Solved!
    Go to Solution.

    Hi,
         I'm fairly new to the NI forums too and I think you just have to wait longer.  Your post was done right.  I do a similiar function as to what you are talking about except I read in numbers from a file.  I create an ini file (just a notepad file of type *.ini) that is is set up with sections inside brackets [] and keys with whatever name followed by an = sign.  You may be able to use a *.dat file too, I just haven't.  Then the vi attached goes to that file and reads the keys from those sections.  You just repeat for the different sections and keys you want to read.  You can use similar provide VI's to write to that same file or create it.  Let me know how that works. 
    Attachments:
    Help1.ini ‏1 KB
    Help1.vi ‏10 KB

  • How to read from a file

    hello friends i m a newbie in java n as i m self studying java, i got stuck on the input streams.sir could u please help me how to read a file named test.txt from following code.
    import java.io.*;
    class ShowFile {
    public static void main(String args[])
    throws IOException
    int i;
    FileInputStream fin;
    try {
    fin = new FileInputStream(args[0]);
    } catch(FileNotFoundException exc) {
    System.out.println("File Not Found");
    return;
    } catch(ArrayIndexOutOfBoundsException exc) {
    System.out.println("Usage: ShowFile File");
    return;
    // read bytes until EOF is encountered
    do {
    i = fin.read();
    if(i != -1) System.out.print((char) i);
    } while(i != -1);
    fin.close();
    }

    sir i heartly appericiate ur quick response the problem in above code is that i have copied the above code from a book which i m reading but it hasn't included any file for reference whch i can test the code upon ie when it is being compiled n runned the no file found error is indicated

  • How to Read from two file and write to another file --Please help !!

    Hi all,
    Please suggest me where i'm goin goin wrng.
    I have 2 flat files. one of them is the main file(Ann.dat) has a about 150,000 lines (each line has unique ID from 00001 to 45000) of data and the the other(Miss.dat) has a just a list of IDs that are no longer in use & have to be deleted from the first file(NewAnn.dat). (Note that Ann.dat is a tab delimitted file and Miss.dat is just a list of all invalid IDs)
    Below is my code. It doesn't do what I'm supposed to. Please suggest me or help me with a code to do it. What I'm trying to do is read each of the lines from the 2 files compare the ID in ann.dat with all the IDs in Miss.dat & if it doesn't match with the ID in Miss.dat write the whole line to NewAnn.dat. And do the rest with all the lines in Ann.dat.
    It could be a real dumb question. since i'm not a software professional, I consider myself to be newbie to programming. I desperately need your help.
    import java.io.*;
    import java.util.*;
    public class anntemp{
         public static void main(String[] args)
              String keyAnn ="";
              String keyMis="";
              String recAnn =null;
              String recMis =null;
              try{               
              FileReader fr=new FileReader("C:\\Tom\\Ann.dat");
              BufferedReader br=new BufferedReader(fr);
              int couter=0;
              while ((recAnn = br.readLine())!=null)
                   couter++;
                   keyAnn = recAnn.substring(0, recAnn.indexOf("\t"));
              FileReader fr1=new FileReader("C:\\Tom\\Miss.dat");
              BufferedReader br1=new BufferedReader(fr1);
              while((recMis = br1.readLine())!=null){
              keyMis = recMis.substring(0, recMis.indexOf("\t"));
                   if(keyAnn.equals(keyMis)){
         FileWriter fw=new FileWriter("C:\\Tom\\NewAnn.dat",true);
         BufferedWriter bw=new BufferedWriter(fw);
         PrintWriter pw=new PrintWriter(bw);
         StringBuffer writeValue = new StringBuffer();
         writeValue.append(recAnn);
                                                 pw.println(writeValue.toString());
         pw.flush();
              }catch (Exception expe){
                   System.out.println("In Exception ");
                   expe.printStackTrace();
    Thank you all in advance,
    br

    I think you need to close the files when you are done in the inner loop. Plus I think you'll be overwritting the file in the inner loop if more than one match. It might be easier to read the unused id file into a map at the start, and then loop up the id's from the master file in the map. You can put the unused id's in as the keys, and a Boolean.TRUE as the value (value won't matter). Then just check if the map contains the key for the id read from the master file. That should cut down on disk activity. This assumes the unused id file is smallish.

  • How to read from input file and pass to script

     How can I get rid of the hard coded PATH statement and feed script based upon text file input.
       Input is contained in a file..
    'C:\cntprocess\   called sistemfolder.txt that has 2 fields folder
    then shortname.
    example:
     C:\cntprocess\REW1___1~Rew1
     C:\cntprocess\REW2___1~Rew2
     I want the first part in each record passed to script for processing
    C:\cntprocess\REW1___1
    C:\cntprocess\REW2___1
    Pass those values to this Script: I want values from above passed to the $Path
    $path='C:\Sistemi\'
    get-childitem -path $path *.spx | % {
    " Starting File Process....." >> $path\sistem.log
    $PDate = get-date
    $date = get-date -uformat "_%d_%m_%Y_%H%M%S.bak"
    #"Set backup date to $date" >> $path\sistem.log
    $newname=($_.fullname -replace ".spx",$date)
    $file = [System.IO.Path]::GetFileNameWithoutExtension($_.fullname)
    "File backup name is $newname" >> $path\sistem.log
    Rename-Item $_.fullname $newname
    "Renamed file to $newname" >> $path\sistem.log
    $lines = get-content $newname
    foreach ($line in $lines)
    $line + " " + [System.IO.Path]::GetFileNameWithoutExtension($_.fullname) | Out-File "$path\sistem.csv" -append
    Write-Host $_.fullname
    "Files Processed on $PDate are $newname " >> $path\sistem.log
    Thanks.

    OK, I was mistaken a bit on what I originally told you. After you run the command of
    $myFile = Import-Csv -Delimiter '~' -Path $path -Header Path, ShortName
    $myFile is actually an array of PSCustomObjects, so you cannot access it like $myFile.Path, you will actually have to loop through the $myFile first, so try changing your script to be the following and see if that helps any
    param
    [string]$path
    $myFiles = Import-Csv -Delimiter '~' -Path $path -Header Path, ShortName
    # Then you can call it like so
    $myFiles.Path #Returns just the path
    $myFiles.ShortName # Returns the shortname
    $path='C:\AreaSistemi1\'
    foreach ($myFile in $myFiles)
    get-childitem -path $myFile.Path *.spx | % {
    " Starting File Process....." >> $myFile.Pathsistem.log
    $PDate = get-date
    $date = get-date -uformat "_%d_%m_%Y_%H%M%S.bak"
    #"Set backup date to $date" >> $path\sistem.log
    $newname=($_.fullname -replace ".spx",$date)
    $file = [System.IO.Path]::GetFileNameWithoutExtension($_.fullname)
    "File backup name is $newname" >> $myFile.Pathsistem.log
    Rename-Item $_.fullname $newname
    "Renamed file to $newname" >> $myFile.Pathsistem.log
    $lines = get-content $newname
    foreach ($line in $lines)
    $line + " " + $myFile.ShortName | Out-File "$path\sistem.csv" -append
    Write-Host $_.fullname
    "Files Processed on $PDate are $newname " >> $path\sistem.log
    Also looking at your script, you said your text file contained the format of <filePath>~<shortname> but I see you doing a $myFile.Pathisstem.log, where does the Pathisstem.log come from?
    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.
    Don't Retire Technet

  • How to read from pdf file using VB

    I have a PDF file which contains three columns, emp no, designation, contact_info. I have 10 rows in that pdf file. I want to read row by row from the pdf file and write into another text file(tab delimited) using VB.
    Could you please help me reading the pdf file?
    Thanks,
    Arindam

    Without reading it in detail, this seems to be automating a save as text function in Acrobat. This will not give you any position information.
    If you want position information without writing a plug-in, you need to use the getPageNthWord and getPageNthWordQuads methods in JavaScript.
    If you have not already done so, you will need to download the Acrobat SDK which has the documentation you need.
    Writing in C# makes even very simple things complicated; if you have a choice, consider VB.

  • How to read from one file and write into another file?

    Hi,
    I am trying to read a File and write into another file.This is the code that i am using.But what happens is last line is only getting written..How to resolve this.the code is as follows,
    public String get() {
         FileReader fr;
         try {
              fr = new FileReader(f);
              String str;
              BufferedReader br = new BufferedReader(fr);
              try {
                   while((str= br.readLine())!=null){
                   generate=str;     
              } catch (IOException e1) {
                   e1.printStackTrace();
              } }catch (FileNotFoundException e) {
                   e.printStackTrace();
         return generate;
    where generate is a string declared globally.
    how to go about it?
    Thanks for your reply in advance

    If you want to copy files as fast as possible, without processing them (as the DOS "copy" or the Unix "cp" command), you can try the java.nio.channels package.
    import java.nio.*;
    import java.nio.channels.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    class Kopy {
         * @param args [0] = source filename
         *        args [1] = destination filename
        public static void main(String[] args) throws Exception {
            if (args.length != 2) {
                System.err.println ("Syntax: java -cp . Kopy source destination");
                System.exit(1);
            File in = new File(args[0]);
            long fileLength = in.length();
            long t = System.currentTimeMillis();
            FileInputStream fis = new FileInputStream (in);
            FileOutputStream fos = new FileOutputStream (args[1]);
            FileChannel fci = fis.getChannel();
            FileChannel fco = fos.getChannel();
            fco.transferFrom(fci, 0, fileLength);
            fis.close();
            fos.close();
            t = System.currentTimeMillis() - t;
            NumberFormat nf = new DecimalFormat("#,##0.00");
            System.out.print (nf.format(fileLength/1024.0) + "kB copied");
            if (t > 0) {
                System.out.println (" in " + t + "ms: " + nf.format(fileLength / 1.024 / t) + " kB/s");
    }

Maybe you are looking for

  • 13" Macbook Pro with retina or MacBook Air?

    Hello All, This is my first post to this forum and I need an advice for buying my first MacBook ever. The time has come that I have decided to invest into a Mac and have always been a PC user until now. I was planning to buy the 13" 256GB version (15

  • How can I create a link that allows users to convert a Wiki pages into PDF format.

    I am working on an enterprise Wiki library site collection, but I want to create a link named "Convert to PDF" , which allow users to convert the current Wiki into a pdf file. I need this link to be displayed some where in all the exsiting Wikis page

  • EDI order Segregation

    Hi i'm new to EDI environment! The requirement is to make EDI robust enough to handle software orders(ZSW order type) in addition to the regular orders(ZEDI and ZCAT).We have a third party tool which submits order to Sap from sources like(customers o

  • Switchover primry to standby

    Hi, is it neccessry creation of standby redo log files on primary for switching ?

  • Photoshop crashes when i open a file: reading photoshop format & crashes

    My Photoshop was working fine, then i tried to open an already existing file and a progress bar comes up and tells me : Reading Photoshop Format, it seems to stick at the beginning of the progress bar and then photoshop just crashes and closes. I can