Frequency of numbers in txt file

hi,
iam a newbie in java,just started learning it.
i have numbers (only from 1 to 5) input typically at run time the input breaks only if i enter -1. , these will be saved to a txt file,numbers.txt. now my problem is to count the frequency of numbers enterted in the txt file and ouput the result to another txt file(output.txt), i know the logic , but not completely sure how to implement it .
import java.io.File;
import java.util.Formatter;
import java.util.Scanner;
public class StudentPoll{
private Scanner x;
int[] frequency = new int[5];
int count =0;
public void openFile(){
try{
x = new Scanner(new File("numbers.txt"));
catch(Exception e){
System.out.printf("No File found");
public void readFile(){
while(x.hasNext()){
int a= x.nextInt();
switch(a){
case 1:
++frequency[0];
case 2:
++frequency[1];
case 3:
++frequency[2];
case 4:
++frequency[3];
case 5:
++frequency [4];
for(int rating =1; rating<=frequency.length;rating++){
System.out.printf("%s%10s\n","rating","Frequency");
System.out.printf("%6d%10d\n",rating,frequency[rating]);
public void closeFile(){
x.close();
and in the main method
StudentPoll read = new StudentPoll();
read.openFile();
read.readFile();
read.closeFile();
also, here i was just trying to get the output right on the console first, i don't how to write it to the txt file (output.txt)
and when i run this always the Frequency counter remains 1.
o/p when i run
run:
Enter integer result (1 - 5), -1 to quit: 1
Enter integer result (1 - 5), -1 to quit: 2
Enter integer result (1 - 5), -1 to quit: 1
Enter integer result (1 - 5), -1 to quit: 2
Enter integer result (1 - 5), -1 to quit: 3
Enter integer result (1 - 5), -1 to quit: 4
Enter integer result (1 - 5), -1 to quit: -1
rating Frequency
1 1
rating Frequency
2 1
rating Frequency
3 1
rating Frequency
4 1
rating Frequency
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
     at StudentPoll.readFile(StudentPoll.java:49)
     at CreateResults.main(CreateResults.java:84)
Java Result: 1
BUILD SUCCESSFUL (total time: 10 seconds)
Kindly somebody please help and guide me what was i doing wrong.
Edited by: 988824 on Feb 18, 2013 10:18 PM

here i have modified the code, but still getting the error in the count
import java.io.File;
import java.util.Formatter;
import java.util.Scanner;
public class StudentPoll_dasariHaritha {
private Scanner x;
int[] frequency = new int[5];
int count =0;
public void openFile(){
try{
x = new Scanner(new File("numbers.txt"));
catch(Exception e){
System.out.printf("No File found");
public void readFile(){
while(x.hasNext()){
int a= x.nextInt();
if(a==1){
frequency[0]=0;
++frequency[0];
break;
else if (a== 2){
frequency[1]=0;
++frequency[1];
break;
else if( a==3){
frequency[2]=0;
++frequency[2];
break;
else if (a==4){
frequency[3]=0;
++frequency[3];
break;
else if (a== 5){
frequency[4]=0;
++frequency [4];
break;
System.out.printf("%s%10s\n","Rating","Frequency");
System.out.printf("%s%10s\n","1",++frequency[0]);
System.out.printf("%s%10s\n","2",++frequency[1]);
System.out.printf("%s%10s\n","3",++frequency[2]);
System.out.printf("%s%10s\n","4",++frequency[3]);
System.out.printf("%s%10s\n","5",++frequency[4]);
public void closeFile(){
x.close();
in the main method iam calling these methods
StudentPoll_dasariHaritha read = new StudentPoll_dasariHaritha();
read.openFile();
read.readFile();
read.closeFile();
i think in the while loop iam making a mistake. can someone help me in rectifying it.

Similar Messages

  • Replace the text numbers string in a txt file using C++.. Help Me..

    Read a Document and replace the text numbers in a txt file using c++..
    For ex: 
    Before Document: 
    hai hello my daily salary is two thousand and five and your salary is five billion. my age is 
    twenty-five. 
    After Document: 
    hai hello my daily salary is # and your salary is #. my age is #. 
    All the text numbers and i put the # symbol.. 
    I am trying this code: 
    #include <iostream>
    #include <fstream>
    #include <string>
    using namespace std;
    ifstream myfile_in ("input.txt");
    ofstream myfile_out ("output.txt");
    string line;
    void find_and_replace( string &source, string find, string replace ) {
    size_t j;
    for ( ; (j = source.find( find )) != string::npos ; ) {
    source.replace( j, find.length(), replace );
    myfile_out << source <<endl;
    cout << source << endl;
    int main () {
    if (myfile_in.is_open())
    int i = 0,j;
    //string strcomma ;
    // string strspace ;
    while (! myfile_in.eof() )
    getline (myfile_in,line);
    string strcomma= "two";
    string strspace = "#";
    find_and_replace( line , strcomma , strspace );
    i++;
    myfile_in.close();
    else cout << "Unable to open file(s) ";
    system("PAUSE");
    return 0;
    Please help me.. Give me the correct code..

    Open the file as a RandomAccessFile. Check its length. Declare a byte array as big as its length and do a single read to get the file into RAM.
    Is this a simple text file (bytes)? No problem. If it's really 16-bit chars, use java.nio to first wrap the byte array as a ByteBuffer and then view the ByteBuffer as a CharBuffer.
    Then you're ready for search/replace. Do it as you would in any other language. Be sure to use System.arraycopy() to shove your bytes right (replace bigger than search) or left (replace smaller than search).
    When done, a single write() to the RandomAccessFile will put it all back. As you search/replace, keep track of size. If the final file is smaller than the original, use a setLength() to the new size to avoid extraneous data at the end.

  • Read numbers from a .txt file and display them in a graph

    How can I get Labview 7 to read from a txt. file containing a lot of
    coloumns with different datas? There`s only two of the coloumns that are
    interesting to me, the first, that contains the time of the measuring, and
    one in the middle, that contains the measured temperatures. I want Labview
    to read this datas and display them graphicly.
    Thanks from Stale

    Here's one way.
    You can also use the help-> find examples and search for "text".
    2006 Ultimate LabVIEW G-eek.
    Attachments:
    Graph.vi ‏21 KB

  • How to read the data in a txt file on a web site?

    I want to extract the numbers located in txt files on a web site. It's a normal url. Not a ftp.
    Does anyone know how to do it?

    Hi Tom,
    What do you want to extract from the text file??
    I wanted to extract an IP address from a pearl script from my FTP server and this was the vi that I used .I dont know if you are trying to do the same?
    Here is the vi.It is in LV 7.1
    Hope its helps .
    Good luck.
    ohiofudu.
    Certified LabVIEW Architect
    Certified TestStand Developer
    Attachments:
    PublicIP-Adresse.vi ‏31 KB

  • How to read data from a .txt file in real time

    Hi
    I am running a fortran code which takes around 1 week to run and output data are continuously saved in .txt files. I want to display these data and plot it against time in labview.
    Lets say I have a array of real numbers starting from 1.0 , and every 2-3 sec another number is added (output of code). So I dont want end-of-file-reached error in my program and also want program to wait until next data is updated in .txt file.
    I tried to make a simple read_txt_file.vi, but I am getting problems in terms of continous reading. Help !! Help !!
    Pl see the attached vi.
    Thanx
    PKJ
    Attachments:
    FileReader.vi ‏43 KB
    labview.txt ‏18 KB

    Hi PKJ,
          I modified your VI and it seems to do what you asked, that is, display the data from a file as the data is being added.
    Hope it helps!
    Message Edited by Dynamik on 11-08-2005 04:32 PM
    Message Edited by Dynamik on 11-08-2005 04:34 PM
    When they give imbeciles handicap-parking, I won't have so far to walk!
    Attachments:
    FileReader.vi ‏52 KB

  • .INI files vs .TXT files for changing default values in a .EXE?

    Hi,
    I have a two-part question related to updating the default values of controls in an executable:
    I am creating a LabVIEW executable for installation on two different production-floor computers.   I need to be able to change the default values of the front panel controls (as I would do with the “make this value default” command during development). From reading prior posts, I understand that I could use the “Write Configuration Settings File.vi” and “Read Configuration Settings File.vi” to generate a .INI file that would be read by the .EXE and would establish the desired values of the controls. However when I took a look at the block diagrams for those configuration .VIs, they don’t appear (to me) to be any easier to use than just reading values from a spreadsheet file. IE: Instead of using these configuration files and a .INI file, could I not instead just read values from a .TXT file that contains the desired values?   I’ve never used a .INI file before, or had to worry about “keys” and “sections,” so from my (perhaps naïve) perspective, the .INI method seems less easy to use. Is there any advantage to the .INI format?
    Regardless of whether I use the .INI file or a .TXT file, I have this additional problem: One of the things that changes when I install my .EXE file on a new computer is the COM port numbers used by two serial devices.   (On my development computer, the two serial devices use COM5 and COM6, whereas on the two production-flood computers, the COM ports will almost certainly be different).   I suppose I could use the Device Manager on the production-floor computers to change the COM ports to be the same as those on my development computer, but I’d prefer to be able to (again) change the default value of the COM ports in my .EXE.   However, I’m not sure how to do that.   The configuration VIs, have options for reading / writing Booleans, strings, paths, and numeric, but not, (so far as I can tell) for a VISA class.
    Any thoughts / suggestions are welcome. Thanks.
    Solved!
    Go to Solution.

    Dan_the_Clam wrote:
    Thanks for your reply, Yamaeda,
    Great that I can use a string to open a VISA session - I had no idea.  I'll try that.  
    And - ah - you are right about the .INI files.  I just did an experiment in which I re-ordered the sections and randomly changed which letters were capitalized in the key values, and the "read configuration settings.VI" still read the file correctly.  Thanks for that.
    Unfortunately, in my existing code, the controls on the block-diagram aren't all co-located together; they are scattered throughout the block diagram - some of them in case structures and loops.   I suppose that means I'll have to move them all to the left side of the block diagram, route them to these "Write Key.VIs" and then wire them up into the cases and loops with fairly long wires.   It's just a hassle, and is going to make my block diagram more complicated.  Well, I suppose that's how one learns...
    Thanks again.
    dan
    Assuming you have a state machine and an Init state it's a fair use of Local Variables to update controls from the ini-file. The same goes for saving the values.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Wrongly transformed the sentences of left and right paragraphs into one sentence in PDF files to txt files by Acrobat 9 Pro

    I found that the when transforming PDF files into TXT files by Acrobat 9 Pro, the Acrobat will wrongly transform the sentences of the left hand side and right hand side paragraphs into one sentence, while the correct format should be the later sentence follows the former sentence in each paragraph.
    An example PDF is : http://cardiovascres.oxfordjournals.org/content/cardiovascres/45/1/200.full.pdf
    Is there any solution for this problem? Or should I use other software (or other version of Acrobat) to solve the problem? Thank you.

    PDF is not a word processor file format.
    It has no "styles", "format", "layout", "columns", "rows", "tables", etc.
    PDF writers paint the content to the canvas that is the PDF page.
    Depending on what was used and how it operates this painting can be like a paint by numbers affair.
    ISO 32000-1:2008, the ISO standard for PDF explains it all.
    So, when exporting to text from your PDF the progression is left to right, top down.
    Remember, PDF has no awareness of "columns". What we see is our construct not PDF's.
    What you and I see as two columns with a specific read order is our imposition.
    What is on the PDF page is simply a line of text characters.
    That is how it is with all versions of Acrobat. Applications can only make use of what the file format supports eh.
    What to do?
    Master content in a logical hierarchy in the authoring file.   
    Always use the build-in Headings for Headings.     
    Use the built-in "table" feature.  
    Use a PDF writer process that is compliant with the ISO standard and that supports proper output of Tagged PDF.   
    A well-formed Tagged PDF will export properly.  
    Two key design considerations for Tagged PDF are:  
    (1)  Support Accessible PDF   
    (2)  Support Export of PDF page content. 
    What constitutes a "well-formed tagged PDF?"
    This would be a PDF that is ISO 14289-1, PDF/UA-1 compliant.
    Be well... 

  • Export Excel Table in .txt File with space delimited text in UNICODE Format

    Hi all
    I've a big unsolved problem: I would like to convert an Excel table with some laboratory data in it (descriptions as text, numbers, variables with some GREEK LETTERS, ...). The output should be a formatted text with a clear structure. A very good solution is
    given by the converter in Excel "Save As" .prn File. All works fine, the formattation is perfect (it does not matter if some parts are cutted because are too long), but unfortunately the greek letters are converted into "?"!!!
    I've tried to convert my .xlsx File in .txt File with formatting Unicode and the greek letters are still there! But in this case the format is not good, the structure of a table is gone!
    Do you know how to save an Excel file in .prn but with Unicode formatting instead of ANSI or a .txt with space delimited text?
    Thanks a lot to everyone that can help me!
    M.L.C.

    This solution works in Excel/Access 2013.
    Link the Excel table into Access.
    In Access, right-click the linked table in the Navigation Pane, point your mouse cursor to "Export", and then choose "Text File" in the sub-menu.
    Name the file, and then under "Specify export options", check "Export data with formatting and layout".  Click "OK".
    Choose either Unicode or Unicode (UTF-8) encoding.  Click "OK".
    Click "Close" to complete the export operation.

  • Problem when I upload txt files to the server

    Hi, I have a problem when I try to upload files to the server, and I can't understand the fail.
    My case is:
    I have a jsp page where a from is.
    This form is sended to a servlet that proccess its content and upload the attach file to the server.
    It works correctly (it uploads the files, txt, xls and csv), the problem is when I try to upload a txt file like this, for example:
    Depth     Age
    0     0,1
    2     0,9
    3     2
    5     6
    6     9
    8     12
    34     25
    56     39
    101     40When I verify the uploaded file, this one has a character extra of return of line (a small square). This character prevents me from working then correctly with the file, on having detected a column of more.
    Which can be the problem?
    The code I use to uploaded the file is:
    try
        MyConnection Objconnection = new MyConnection();
        boolean isMultipart = FileUpload.isMultipartContent(req);
        // Create a factory for disk-based file items
        FileItemFactory factory = new DiskFileItemFactory();
         // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);
        // Set overall request size constraint
        upload.setSizeMax(1024*512); //524288 Bytes (512 KB)
         // Parse the request
        List items = upload.parseRequest(req);
        // Process the uploaded items
        Iterator iter = items.iterator();
        String dat = new String();
        String typeFile = new String();
        while (iter.hasNext())
            FileItem item = (FileItem) iter.next();
            if (item.getFieldName().equals("typeFile") )
                typeFile = item.getString();
            if (!item.isFormField())
            String fieldName = item.getFieldName();
            String fileName = item.getName();
            String contentType = item.getContentType();
            boolean isInMemory = item.isInMemory();
            long sizeInBytes = item.getSize();
            int numbers=0;
            for(int i=fileName.length();(i=fileName.lastIndexOf('\\',i-1))>=0;)
                 numbers++;
            String stringFile[] = fileName.split("\\\\");
            HttpSession session = req.getSession(true);
            String loginSesion = (String)session.getAttribute("UserLogin");
            String newUserFolder = loginSesion;
            File createFile = new File("/usr/local/tomcat/webapps/Usuarios/FilesUp/"+newUserFolder);
            if ("AgeModel".equals(typeFile))
                createFile = new File("/usr/local/tomcat/webapps/Usuarios/FilesUp/AgeModels/"+newUserFolder);
            if (!createFile.exists())
                createFile.mkdir();
            fileName = stringFile[numbers];
            File uploadedFile = new File("/usr/local/tomcat/webapps/Usuarios/FilesUp/"+newUserFolder+"/"+fileName);
            if ("AgeModel".equals(typeFile) )
                uploadedFile = new File("/usr/local/tomcat/webapps/Usuarios/FilesUp/AgeModels/"+newUserFolder+"/"+fileName);
            existe = Objconnection.existFile(fileName, typeFile, loginSesion);
            if ( true == existe )
                 exito = false;
            else
                item.write(uploadedFile);
                ....// NOW REGISTER THE FILE IN TH DATA BASE
        } // if (!item.isFormField())
    } // WHILE ( iter.hasNext() )
                catch(Exception e) {
                out.println("Error de Aplicaci�n " + e.getMessage());
                return exito;
    ...THANKS

    Hi,
    Sorry I am aware this question was posted way back, but I am having similar problem and haven't been able to find the fix yet.
    So please let me known if you have got any ideas.
    My problem is same that I have to upload a CSV file from Client Machine (Windows) to Unix Application Server.
    I am using JSP method post and multipart/form-data (as in http://www.roseindia.net/jsp/file_upload/Sinle_upload.xhtml.shtml).
    The file is uploaded fine but the problem is it displays carraige Return (^M) a square boxes on Unix file.
    I can't ask user to convert file to Unox format before uploading. They just convert excel file to CSV and upload.
    Is there any way I can get rid of these characters as I have to use this file further.
    Sorry, I can't use any paid utility or tool for it.
    I would appreciate if you could please help.
    Thanks,
    SW

  • How to read data from txt file respectively

    Hi,
    I am triying to form an equation between two known points. I want to do this with the attached VI, the most critical point is that I will read the x1, y1, x2 and y2 coordinates from the same .txt file. They will be written in a .txt file and I will send them to the appropriate channel (x1, y1, x2 and y2) respectively. How can I get data in a rule from a .txt file?
    Could anyone please help me with this issue,
    Best regards. 
    Attachments:
    read from txt file.vi ‏8 KB

    Dear RavensFan,
    Thank you very much for your helps, I am bit new to labview so I usually can not find the appropriate functions easily. And a new problem has rised in my application. I should write the A, B and C numbers in the respective series to the file 2.txt. I am able to write them in a straight forward case but I want to write the next triples (A B C) in the next row. Like this;
    A1 B1 C1
    A2 B2 C2
    A3 B3 C3
    So how can I put new line constant and space constant to my VI? 
    Waiting for your valuable helps,
    Best regards,
    Attachments:
    read_from_txt_fileMOD.vi ‏18 KB

  • Importing fixed width text from a .txt file

    I am really struggling to do in Numbers '09 something which I can do easily in Excel.
    I have a txt file containing plain text in fixed-width columns which I would like to import into numbers.
    I just cannot find a way to do it.
    I have tried using the Insert/choose menu item - but it won't take .txt files.
    I have tried to copy/paste the data, but it get's pasted into a single column.
    The data consists of many lines like this:
    Part Value Device Package Library Sheet
    A-IN JST-2.0-4 JST-2.0-4 JST-20M KMILLAR 1
    A-IN JST-2.5-4 JST-2.5-4 JST-25M KMILLAR 1
    A-IN JST-2.8-4 JST-2.8-4 JST-28M KMILLAR 1
    (and so on....)
    (Each column is an exact number of characters wide, but these forums make that hard to see due to the variable spaced fonts).
    How can I import this data into numbers?
    (Sorry, but I cannot get the data in any other format, such as CSV, the application which exports it only support fixed width colums with spaces for padding).
    Many thanks in advance,
    Kenny

    Here is a script treating the case of fixed widths values.
    --[SCRIPT fixedwidth_values_toTSV.scpt]
    Enregistrer le script en tant que Script : fixedwidth_values_toTSV.scpt
    déplacer le fichier ainsi créé dans le dossier
    <VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
    Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
    aller au menu Scripts , choisir Numbers puis choisir fixedwidth_values_toTSV
    Choisir un fichier texte.
    Le script détermine la largeur des différentes colonnes puis remplace les groupes séparateurs par des caractères TAB.
    Le résultat est passé dans le presse-paiers et est enregistré à la place du contenu initial.
    Vous pouvez alors
    (1) coller dans le document de votre choix
    (2) ouvrir le fichier texte modifié dans Numbers qui accepte sans broncher les ficiers .txt.
    Utilisation alternative : enregistrer le script en tant que Progiciel (Application sous 10.6.x)
    Glisser-déposer l'icône d'un fichier texte sur celle de l'application lancera le traitement voulu.
    --=====
    L'aide du Finder explique:
    L'Utilitaire AppleScript permet d'activer le Menu des scripts :
    Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
    Cochez la case "Afficher le menu des scripts dans la barre de menus".
    Sous 10.6.x,
    aller dans le panneau "Général" du dialogue Préférences de l'Éditeur Applescript
    puis cocher la case "Afficher le menu des scripts dans la barre des menus".
    --=====
    Save the script as a Script: fixedwidth_values_toTSV.scpt
    Move the newly created file into the folder:
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
    Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
    go to the Scripts Menu, choose Numbers, then choose "fixedwidth_values_toTSV"
    Choose a text file.
    The script scan the file's contents to extract the width of every column then it replace the separator groups by TAB characters.
    The result is passed to the clipboard and is written in the original file.
    So you may :
    (1) paste in the document of your choice
    (2) open the modified text file with Numbers which is fair enough to do that.
    An alternate track is to save the script as an Application Package (Application under 10.6.x)
    Drag and drop the icon of a text file on the application's one will do the job.
    --=====
    The Finder's Help explains:
    To make the Script menu appear:
    Open the AppleScript utility located in Applications/AppleScript.
    Select the "Show Script Menu in menu bar" checkbox.
    Under 10.6.x,
    go to the General panel of AppleScript Editor’s Preferences dialog box
    and check the “Show Script menu in menu bar” option.
    --=====
    Yvan KOENIG (VALLAURIS, France)
    2010/08/19
    --=====
    on run
    set un_fichier to choose file with prompt "Choose e text file…" of type {"public.plain-text"} without invisibles
    my commun(un_fichier)
    end run
    --=====
    on open (sel)
    set un_fichier to item 1 of sel
    tell application "System Events" to set type_ID to type identifier of disk item ("" & un_fichier)
    if type_ID is "public.plain-text" then my commun(un_fichier as alias)
    error "The file “" & un_fichier & "” isn’t a text file !"
    end open
    --=====
    on commun(le_fichier)
    set le_contenu to read le_fichier
    set le_contenu to "azer ertyuio wxcv dfghj
    qszaed dc fghj mlkjhgf nbvcxw
    aqwzsx edcrfv tg byhn aaaaaaa "
    set listedelistes to {}
    set plusgrandelongueur to 0
    set pluspetitelongueur to 999999
    set listelignesbrutes to paragraphs of le_contenu
    repeat with refd_uneligne in listelignesbrutes
    set maybe to contents of refd_uneligne
    set maybe2 to count of maybe
    if maybe2 > plusgrandelongueur then set plusgrandelongueur to maybe2
    if maybe2 < pluspetitelongueur then set pluspetitelongueur to maybe2
    copy my decoupe(maybe, space) to end of listedelistes
    end repeat
    set differencedelongueur to plusgrandelongueur - pluspetitelongueur
    set des_espaces to space
    repeat differencedelongueur times
    set des_espaces to des_espaces & space
    end repeat
    set largeur1 to 0
    repeat with refd_uneligne in listedelistes
    set maybe to length of first item of refd_uneligne
    if maybe > largeur1 then set largeur1 to maybe
    end repeat
    set liste_finale to {}
    repeat with refd_uneligne in listelignesbrutes
    set maybe to contents of refd_uneligne
    set maybe2 to text 1 thru largeur1 of maybe
    repeat while maybe2 ends with space
    set maybe2 to text 1 thru -2 of maybe2
    end repeat
    copy maybe2 to end of liste_finale
    copy text (largeur1 + 2) thru plusgrandelongueur of (maybe & des_espaces) to contents of refd_uneligne
    end repeat
    Enter the bigger loop *)
    set cest_Lafin to false
    repeat
    Deprieve the stored rows of the treated column's items *)
    set flag to 0
    repeat
    set flag to flag + 1
    set flag2 to 0
    repeat with refd_uneligne in listelignesbrutes
    if "" & character flag of contents of refd_uneligne is space then set flag2 to flag2 + 1
    end repeat
    if flag2 < (count of listelignesbrutes) then exit repeat
    end repeat
    repeat with refd_uneligne in listelignesbrutes
    copy text flag thru -1 of contents of refd_uneligne to contents of refd_uneligne
    end repeat
    Prepare the extraction of next column *)
    repeat with refd_uneligne in listelignesbrutes
    copy my decoupe(contents of refd_uneligne, space) to end of listedelistes
    end repeat
    Extract the width of the column to treat *)
    set largeur1 to 0
    repeat with refd_uneligne in listedelistes
    set maybe to length of first item of refd_uneligne
    if maybe > largeur1 then set largeur1 to maybe
    end repeat
    Extract the column's values *)
    repeat with i from 1 to count of listelignesbrutes
    set maybe to contents of item i of listelignesbrutes
    set maybe2 to text 1 thru largeur1 of maybe
    repeat while maybe2 ends with space
    set maybe2 to text 1 thru -2 of maybe2
    end repeat
    copy (contents of item i of liste_finale) & tab & maybe2 to item i of liste_finale
    try
    copy text (largeur1 + 2) thru -1 of maybe to item i of listelignesbrutes
    on error
    set cest_Lafin to true
    end try
    end repeat -- i
    if cest_Lafin then exit repeat
    end repeat -- bigger loop
    set le_contenu to my recolle(liste_finale, return)
    set the clipboard to le_contenu
    set eof of le_fichier to 0
    write le_contenu to le_fichier
    end commun
    --=====
    on decoupe(t, d)
    local oTIDs, l
    set oTIDs to AppleScript's text item delimiters
    set AppleScript's text item delimiters to d
    set l to text items of t
    set AppleScript's text item delimiters to oTIDs
    return l
    end decoupe
    --=====
    on recolle(l, d)
    local oTIDs, t
    set oTIDs to AppleScript's text item delimiters
    set AppleScript's text item delimiters to d
    set t to l as text
    set AppleScript's text item delimiters to oTIDs
    return t
    end recolle
    --=====
    --[/SCRIPT]
    Yvan KOENIG (VALLAURIS, France) vendredi 20 août 2010 12:44:33

  • Create book file on basis of txt file with local paths?

    I would like to be able to create a book file in FrameMaker 7 or FrameMaker 9 on the basis of a  .txt file reading for instance:
    c:/documents/job.fm
    c:/documents/15ss.fm
    c:/documents/sdf/job1.fm
    Preferrably I would like to be able to paste the lines into a prompt and have a script compiling the book file.
    Is it possible to write a script using FrameMakers API which would do this trick? It is probably possible to use FrameScript but I am not too keen on FrameScript and would rather avoid it.
    Who should one ask in order to have such a thing written?
    regards
    Bjørn

    StudioSm wrote:
    I would like to be able to create a book file in FrameMaker 7 or FrameMaker 9 on the basis of a  .txt file reading for instance:
    c:/documents/job.fm
    c:/documents/15ss.fm
    c:/documents/sdf/job1.fm
    Preferrably I would like to be able to paste the lines into a prompt and have a script compiling the book file.
    Is it possible to write a script using FrameMakers API which would do this trick? It is probably possible to use FrameScript but I am not too keen on FrameScript and would rather avoid it.
    Who should one ask in order to have such a thing written?
    regards
    Bjørn
    I started using FrameMaker in release 2.x, while I was using x-roff on UNIX; x-roff used a "makefile" to create books from independent chapters, doing all the pagination, numbering, etc. I suspected that FrameMaker's book file worked like that, but it wasn't until many years later that I met someone who'd worked with FrameMaker version 1.x, who confirmed my suspicion.
    Although I can't tell you how to do it, I'm certain that it can be programmed as you want, and that someone will post more information.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • Array to store .txt file data

    I have a .txt file containing lines like the following:
    1,50000.343,2000.745
    2,25645.856,4600,856
    3,24356.756,8766,345
    I'd like to store the strings as numbers and place them into an array, but I'm unsure how to do so.
    Any help would be appreciated

    The StreamTokenizer class will help you read the input, separating numbers from commas. Once you have the number as a String, the classes like Double and Integer have constructors that accept String arguments and do the hard work for you:
    // someString came from the file
    // you checked to see if it had a "." and it didn't, so
    // you know it's an integer
    Integer myInteger = new Integer( someString );
    int myInt = myInteger.getInt();

  • What's the best way to read/write data from a file (preferabl​y a *.txt file)?

    As in the title.  l have revived a couple of old VIs to read and write three numbers and a 1D array of clusters to/from a *.txt file.  The functionality is not very user friendly, and it would also be useful if one could open the text files (manually - not through LabVIEW) and still be able to see/understand what was there.
    I was wondering if anyone would be able to come up with a more efficient and/or user friendly method (compatible with lv6.1) 
    James
    Never say "Oops." Always say "Ah, interesting!"
    Attachments:
    Read Spec.vi ‏110 KB
    Write Spec.vi ‏58 KB

    My primary goal is to have something that works and is easy and comprehensive to operate.  Generating a human-readable file is just a bonus but would be nice if it could be achieved.
    I enclose pictures of the initial file dialog (for both loading and saving the data - referred to as Spec(s) from hence forth), and of the front panel screen seen when  a) loading a spec and  b) saving a spec.  In the file dialog, you have to already know the exact string to input else you'll just be told the file doesn't exist (applies for both loading and saving).  When saving a spec, you cannot see any files previously saved, nor even any previous specs saved within the file.  This means that one can unwittingly overwrite specs without realising it.
    I'm not sure if I've explained this very well, but the current functionality means that far too much can go wrong.  Additionally, if you forget the file name, you'll have no way of knowing what it should be (the data files are stored on a 'locked' part of our network accessible only by Admin or through the LabVIEW executable
    Never say "Oops." Always say "Ah, interesting!"
    Attachments:
    File Dialog.JPG ‏23 KB
    Select The Required Test Spec.JPG ‏10 KB
    Name of specification.JPG ‏6 KB

  • TXT file generation

    Dear all,
    I was wondering what would be the best way to handle a txt file generation from SAP on a daily basis required for futher treatment by an external system.
    Type of data: SD/MM
    Volume of data is not that big (10 k)
    Frequency once a day (night time)
    Format to be issued is txt
    Would a batch input be the best way?
    Regards.

    Hi Nozome
    Can you please confirm if this query to download data from SAP to application server???
    Sample code:
    Suppose all the data that has to be downloaded to a text file is in internal table itab:
    DATA: fname LIKE RLGRAP-FILENAME VALUE '/usr/sap/down.txt'.
    OPEN DATASET fname FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    IF SY-SUBRC NE 0.
       MESSAGE E001(00) WITH 'Unable to open file.
    ELSE.
       LOOP AT itab.
            TRANSFER itab TO fname.
       ENDLOOP.
       CLOSE DATASET fname.
    ENDIF.
    Hope this gives you some idea.
    Kind Regards
    Eswar

Maybe you are looking for

  • Every time i close FireFox , it do not remeber my proxy settings

    I use FF for my company web development and every time i open it for the first time it shows the error message for the default home page "The proxy server is refusing connections". I have to go to Tools -> options -> Net work Tab -> settings Fix the

  • E5-00 bug in HFP (hands free profile)

    I have a nokia e5-00, a N95 and a 6230i  I connect them all to my Citroen C5 Tourer (which uses bluetooth in its MyWay system). E5-00 has a very strange bug: when someone calls me, the number reported to the car is always preceded by a plus (+) sign:

  • Chat windows aren't opening.

    My AIM buddy list loads but after double clicking on a buddy, no chat window opens. When I expose though, I still get a blank spot where the chat window should be with "5 Chats" underneath it.

  • I can`t use my g mail account?

    Hi i cant use my gmail account, it comes up invalid user name or password Does anyone know why & can you help me please.

  • Transform ED50 to ETRS89

    Hi, Oracle DATABASE 10gR2, 10.2.0.5.0. I know that the coordinate points "A" are (in "ED50" zone 30): X:656615.4735 Y:4269389.2551 I know that the coordinate points "A" are (in "ETRS89" zone 30): x: 656505.1721 y: 4269181.4779 But, transform ED50 in