Importing Text From A .txt File

Hey guys,
I'm looking for a way to import text from a .txt file but I'm totally lost. If someone could point me in the right direction that would be awesome

Hi Prails
This script is basically what you asked:
#target illustrator
#targetengine main
function copyText(){
    var textFile = File.openDialog ("Select the file");
    if (! textFile.exists || app.documents.length==0){
        return;
    textFile.open("r");
    var txtContent = textFile.read();
    textFile.close();
    var doc = app.activeDocument;
    var textItem = doc.textFrames.add();
    textItem.contents = txtContent   
copyText ();
Basically what you need to do is declare the text file, open it, read the content and close it. Then, you create a new text item in the Illustrator document and write the content once catched into the text item.
You could continue to work with the variable "textItem" in my example script if you want to set properties like the size, color of the text, position and so on. Also, if you want, replace the first line of the function var textFile = new File ("~/Desktop/Test.txt"); by var textFile = File.openDialog ("Select the file"); so the scripts opens a dialog to ask you the file you want the copy the content.
Hope to be helped
Best Regards
Gustavo
Message was edited by: Gustavo Del Vechio

Similar Messages

  • Loading text from a .txt file

    I want to do something that should be VERY simple, but due to
    Adobe's insistence on using #$%^ing tutorials instead of just
    providing step by step instructions, it's very frustrating to
    figure out how to do it.
    All I want to do is load the contents of a text file into a
    dynamic text field, but I can't figure out how to do it (I'm not
    all that familiar with AS). I'm working with Flash 8. Please help.
    Thanks.

    Create the dynamic text box, and name it schedule.
    Then, in the frame on the timeline that the text box resides
    in, the corresponding actionscript would be used to create a text
    variable and assign the text from a txt file to it:
    loadText = new LoadVars();
    loadText.load("externalfile.txt");
    loadText.onLoad = function() {
    schedule.text = this.textbody;
    Where does the "textbody" variable come from? In the external
    text file (externalfile.txt in this example), you have a variable
    called textbody, and the externalfile.txt should read along the
    lines of:
    textbody = "I'm the external text that needs to be read
    in"

  • Importing accents from a txt file

    Hi everyone
    I have the following proble that I can't solve for now:
    I've got a pdf file with forms
    I've got an excel file that I export to txt (tab delimited text file)
    When I import the data from the txt file to the pdf everything is fine but the french accents (é or è or à). For example the "é" becomes a " ,".
    I thinks it might be related to unicode or utf but I don't know how to export properly then import those characters.
    Any idea ?
    Thanks
    Florent
    PS: I'm using Excell 2011 on MAC and Acrobat 9 Pro.

    Done that already, no luck.
    I've saved in all the txt formats possible in my Excel.

  • 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

  • How to use automator to extract specific text from json txt file

    I'm trying to set up an Automator folder action to extract certain data from json files. I'm pulling metadata from YouTube videos, and I want to extract the Title of the video, the URL for the video, and the date uploaded.
    Sample json data excerpts:
    "upload_date": "20130319"
    "title": "[title of varying length]"
    "webpage_url": "https://www.youtube.com/watch?v=[video id]"
    Based on this thread, seems I should be able to have Automator (or any means of using a shell script) find data and extract it into a .txt file, which I can then open as a space delimited file in Excel or Numbers. That answer assumes a static number of digits for the text to be extracted, though. Is there a way Automator can search through the json file and extract the text - however long - after "title" and "webpage_url"?
    json files are all in the same folder, and all end in .info.json.
    Any help greatly appreciated!

    Hello
    You might try the following perl script, which will process every *.json file in current directory and yield out.csv.
    * CSV currently uses space for field separator as you requested. Note that Numbers.app cannot import such CSV file correctly.
    #!/bin/bash
    /usr/bin/perl -CSDA -w <<'EOF' - *.json > out.csv
    use strict;
    use JSON::Syck;
    $JSON::Syck::ImplicitUnicode = 1;
    # json node paths to extract
    my @paths = ('/upload_date', '/title', '/webpage_url');
    for (@ARGV) {
        my $json;
        open(IN, "<", $_) or die "$!";
            local $/;
            $json = <IN>;
        close IN;
        my $data = JSON::Syck::Load($json) or next;
        my @values = map { &json_node_at_path($data, $_) } @paths;
            #   output CSV spec
            #   - field separator = SPACE
            #   - record separator = LF
            #   - every field is quoted
            local $, = qq( );
            local $\ = qq(\n);
            print map { s/"/""/og; q(").$_.q("); } @values;
    sub json_node_at_path ($$) {
        #   $ : (reference) json object
        #   $ : (string) node path
        #   E.g. Given node path = '/abc/0/def', it returns either
        #       $obj->{'abc'}->[0]->{'def'}   if $obj->{'abc'} is ARRAY; or
        #       $obj->{'abc'}->{'0'}->{'def'} if $obj->{'abc'} is HASH.
        my ($obj, $path) = @_; 
        my $r = $obj;
        for ( map { /(^.+$)/ } split /\//, $path ) {
            if ( /^[0-9]+$/ && ref($r) eq 'ARRAY' ) {
                $r = $r->[$_];
            else {
                $r = $r->{$_};
        return $r;
    EOF
    For Automator workflow, you may use Run Shell Script action as follows, which will receive json files and yield out_YYYY-MM-DD_HHMMSS.csv on desktop.
    Run Shell Script action
        - Shell = /bin/bash
        - Pass input = as arguments
        - Code = as follows
    #!/bin/bash
    /usr/bin/perl -CSDA -w <<'EOF' - "$@" > ~/Desktop/out_"$(date '+%F_%H%M%S')".csv
    use strict;
    use JSON::Syck;
    $JSON::Syck::ImplicitUnicode = 1;
    # json node paths to extract
    my @paths = ('/upload_date', '/title', '/webpage_url');
    for (@ARGV) {
        my $json;
        open(IN, "<", $_) or die "$!";
            local $/;
            $json = <IN>;
        close IN;
        my $data = JSON::Syck::Load($json) or next;
        my @values = map { &json_node_at_path($data, $_) } @paths;
            #   output CSV spec
            #   - field separator = SPACE
            #   - record separator = LF
            #   - every field is quoted
            local $, = qq( );
            local $\ = qq(\n);
            print map { s/"/""/og; q(").$_.q("); } @values;
    sub json_node_at_path ($$) {
        #   $ : (reference) json object
        #   $ : (string) node path
        #   E.g. Given node path = '/abc/0/def', it returns either
        #       $obj->{'abc'}->[0]->{'def'}   if $obj->{'abc'} is ARRAY; or
        #       $obj->{'abc'}->{'0'}->{'def'} if $obj->{'abc'} is HASH.
        my ($obj, $path) = @_; 
        my $r = $obj;
        for ( map { /(^.+$)/ } split /\//, $path ) {
            if ( /^[0-9]+$/ && ref($r) eq 'ARRAY' ) {
                $r = $r->[$_];
            else {
                $r = $r->{$_};
        return $r;
    EOF
    Tested under OS X 10.6.8.
    Hope this may help,
    H

  • Importing data from a .txt file and have Acrobat create new pages

    Hi everyone,
    I've created a form in Acrobat 9 to be used as an invoice. I want to be able to import data from an excel spreadsheet or .txt file into all the form fields. I know that I can go Forms > Manage form Data > Import Data to import 1 record at a time, but say I have about 50 invoices to populate, is there a way to import all the records at once and have acrobat create a new invoice for each of the customer's records?
    If there is a way, will it be compatible for Acrobat Reader users since this form will be used by someone who only has the Reader?
    Really appreciate any help.

    Sure.. this is what we use. "New Micro Right Click Tools"
    http://www.nowmicro.com/rct/

  • Importing Text from a .txt

    Hi everyone,
    First post here, woo!
    Let's say I have 5 pages (each about 4 frames long), and on
    each page I need to pull in distinctively different text. On page
    1, I need the Bible; page 2, Baghavad Gita; page 3, Yoga
    Sutras...etc. Also, when I pull them in, I need to be able to play
    with them. For example, I need to be able to hide each paragraph
    when I click a button.
    I first thought I'd need to import a text file into a text
    box I pre-defined on the stage, but I can't seem to get that to
    override the text of a MovieClip (come on, I'm a rookie!). Then I
    thought I'd just ActionScript a text box into existence with code.
    Only problem is, I need to animate it to disappear when I click a
    button, and re-appear again (which I achieve with just having it
    scroll off the stage - any suggestions on improving this situation
    would also be much appreciated).
    So, my question is: How do I pull in external text files (or
    internal? - if I'm over-complicating things) onto the stage, so
    that I can animate them to do things like disappear, or move, or
    whatever really?
    Am I making sense? All help would be GREATLY appreciated!
    Cheers
    Marc

    To pull in your external data, I would advise using XML (make
    sure to use CDATA with large text blocks). AS3 has a new beautiful
    way to pull and parse XML Data. Just use a URLLoader/URLRequest to
    get the XML data, then use the E4X Parser built in Flash to parse
    the data, here's an example:
    http://pixelfumes.blogspot.com/2007/05/easy-xml-parsing-using-as3-actionscript.html

  • Importing Arabic text from an XML file

    Importing text from an XML file to appear as text in Flash
    works in English, however if the text I want to import is in
    Arabic, when I test the movie there is no text at all.
    Is there some particular syntax to preface the Arabic text?
    I'll want to import text from XML in other languages too.
    (French)
    I'd cut and pasted some Arabic text into the XML file that
    displays pictures and text in the "slideshow.fla" (
    http://www.adobe.com/support/flash/applications/jpeg_slideshow_xml/jpeg_slideshow_xml03.ht ml)
    Substituting Arabic text for English text, editing the XML
    file with Dreamweaver.
    Any ideas as to how I might achieve my objective of importing
    Arabic text into Fash?
    I'd started developing my prototpe in Macromedia Director 7,
    and then Director MX, but I have not found a suitable Arabic font
    that I can embed that will allow me to display Arabic fonts in
    Adobe Director. I have the Arabic text in a Word document.
    I've dicovered that my Flash MX Pro and Dreamweaver both
    support Arabic fonts, but I want to import text from an XML file.
    I'd prefer using cast libraries and cast members, but I don't
    know of an equivalent in Flash to what I'm comfortable with in
    Director.

    Oh so many questions. You probably aren't going to like the
    answers. I have Flash MX04 pro (aka Flash 7) and things made a big
    jump between MX (aka 6) and MX04. If you only have MX, there might
    not be a way to do this. All my advice is based upon MX04 or
    higher.
    It is possible to do complex languages in Flash. My
    experience is with Hindi and I've helped a few folks here with
    Arabic.
    You won't be able to use text from Microsoft Word – at
    least I don't think so. The XML file will need to be saved in the
    UTF-8 format. I think Word uses its own scheme and won't work. But
    I'm not a Word expert. Something like Text Edit (Mac) or WordPad
    (PC) should be able to save a UTF-8 file.
    The next problem is you mention "suitable Arabic font that I
    can embed." AFAIK, you can't embed any of the complex scripts in
    Flash. You just have to rely on the end user having appropriate
    fonts installed and enabled. Most operating systems from 2000 on do
    have this – although some folks like to remove them to save
    space.
    Next issue will be line composing. I've found that when using
    anything above the normal Latin range that Flash suddenly forgets
    how to make a line fit into a text area. It will just break things
    in the middle of words and not even notice the spaces between
    words. I've written a little snippet of code that "composes" the
    lines. It works well with Hindi and folks here have used it with
    Arabic and not come back saying that it doesn't work. Search the
    forums (both the Flash and Actionscript) if you can't find it I'll
    dig it out when I get home.
    So here is the checklist:
    Make sure the XML is saved in UTF-8
    Import the XML file
    In Testing environment go Debug–>List variables.
    Does it show up correctly there?
    Does it show at all in a text field?
    Use the "composer" to make the lines break.

  • [Win CS5] Import text from *.txt, analyse and place

    Hello everybody!
    I hope this hasn't been posted before, I've used the search function, but haven't found anything...
    This is my problem:
    I have a *.txt file with vocabulary, organised like this:
    vocable<tab>1. translation
    <tab>2. translation
    vocable<tab>translation
    (vocables and traductions are separated by tabs)
    Example:
    suscipio, is, ere, suscepi, susceptum<tab>(ici) prendre sur soi, entreprendre
    deposco, is, ere, depoposci, /<tab>demander avec instance, exiger, réclamer
    injungo, is, ere, injured, injunctum<tab>1. appliquer dans
    <tab>2. joindre à, relier (tecta injuncta muro)
    <tab>3. infliger (injuriam alicui)
    <tab>4. imposer (servitutem alicui)
    I want to place the vocable on a page in a textframe (4x5 textframes on a page), and the translation on the next page in a textframe, at the position where the vocable is located on the back, if you print the two pages duplex on a sheet (so that if you cut the textframes out, the vocable is on one side, the translation on the back). The problem is that I have no idea how to write a script in JavaScript which analyses the text from the *.txt file, and pastes the vocable and its translation in the rigth textframes. Another problem is, if it's easier to generate the textframes first, and paste the text, or to search the vocable and the translation and then generate the textframe and its content :-S
    It'd be kind if anybody could help me with this or give me a hint!
    Thx a lot!
    Jean-Pierre

    But all white color are not the same…
    If your background is the size of the entire book page that's not a problem. Your picture will simply sit on top of your all white background with the letters at the bottom - no chance of seeing an outlined box around it. If there ever was a discernible difference you certainly wouldn't notice it from one page to another. And anyway, won't full white (100%) register as no ink when the book is printed?
    Again, if you're unsure why not just go for the simplest solution? Do your page design in Photoshop (you're already creating your background) and use the book tool to do the final layout and send it out. Sometimes simple is the best answer!

  • How to skip footer details when loading data from a .txt file

    Hello experts,
    i have to import data from a txt file into my database. I have skipped my header info by using SKIP but how can i ignore my footer details.
    Thanks

    Reply on your other thread:
    Processing txt file for a required format

  • Importing text from Word file while keeping formatting

    I have text set up to convert to Goudy Oldstyle. When I try to import formatted text from a Word file, the italics don't translate to Goudy Oldstyle italic. It becomes Goudy Italic and then reads as a conflict. How would I be able to reformat just the italics?

    Find Font is also in CS2 (Type > Find Font). Very easy, very simple.
    In CS2, Find Font doesn't have the same Redefine Style functionality
    that it does in CS3, but you can still find a missing font or font
    variant and replace it with something that's not missing. You would have
    to redefine styles manually, but you can use Find Font to figure out
    which styles need redefining. (That is, if you've used styles; we don't
    know yet because you haven't said.)
    Kenneth Benson
    Pegasus Type, Inc.
    www.pegtype.com

  • How can I import text from a text file located in a dropbox.

    I am trying to add a text box for announcements that a client can update by simply updating the text file in his dropbox.
    I am using Dreamweaver 5
    here is the site www.cvham.org

    If they are going to be updating announcements on a regular basis, seriously consider a CMS alternative like a Wordpress.
    While it is possible if you make the file publicly available and put the URL as an include (ie: in PHP - include([urltodropboxfile]); ) it really isn't recommended.  First, text in a txt file needs to be parsed by the server, otherwise it will come through as one big text block.  Because of that it would be advantageous to just have your client make HTML files.  And second, most shared hosts, which I would assume is what your client is using, disallow remote URLs in includes for security reasons as well as bandwidth reasons because they don't know what the process being included is.  To test this create a php info file and check for the variable "allow_url_include".  If that option is not On or allowed, then you can't include Dropbox files even if you wanted to.

  • I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?

    I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?
    Attachments:
    try2.txt ‏2 KB
    read_array.vi ‏21 KB

    The problem is in the delimiters in your text file. By default, Read From Spreadsheet File.vi expects a tab delimited file. You can specify a delimiter (like a space), but Read From Spreadsheet File.vi has a problem with repeated delimiters: if you specify a single space as a delimiter and Read From Spreadsheet File.vi finds two spaces back-to-back, it stops reading that line. Your file (as I got it from your earlier post) is delimited by 4 spaces.
    Here are some of your choices to fix your problem.
    1. Change the source file to a tab delimited file. Your VI will then run as is.
    2. Change the source file to be delimited by a single space (rather than 4), then wire a string constant containing one space to the delimiter input of Read From Spreadsheet File.vi.
    3. Wire a string constant containing 4 spaces to the delimiter input of Read From Spreadsheet File.vi. Then your text file will run as is.
    Depending on where your text file comes from (see more comments below), I'd vote for choice 1: a tab delimited text file. It's the most common text output of spreadsheet programs.
    Comments for choices 1 and 2: Where does the text file come from? Is it automatically generated or manually generated? Will it be generated multiple times or just once? If it's manually generated or generated just once, you can use any text editor to change 4 spaces to a tab or to a single space. Note: if you want to change it to a tab delimited file, you can't enter a tab directly into a box in the search & replace dialog of many programs like notepad, but you can do a cut and paste. Before you start your search and replace (just in the text window of the editor), press tab. A tab character will be entered. Press Shift-LeftArrow (not Backspace) to highlight the tab character. Press Ctrl-X to cut the tab character. Start your search and replace (Ctrl-H in notepad in Windows 2000). Click into the Find What box. Enter four spaces. Click into the Replace With box. Press Ctrl-V to paste the tab character. And another thing: older versions of notepad don't have search and replace. Use any editor or word processor that does.

  • How to extract text from a PDF file?

    Hello Suners,
    i need to know how to extract text from a pdf file?
    does anyone know what is the character encoding in pdf file, when i use an input stream to read the file it gives encrypted characters not the original text in the file.
    is there any procedures i should do while reading a pdf file,
    File f=new File("D:/File.pdf");
                   FileReader fr=new FileReader(f);
                   BufferedReader br=new BufferedReader(fr);
                   String s=br.readLine();any help will be deeply appreciated.

    jverd wrote:
    First, you set i once, and then loop without ever changing it. So your loop body will execute either 0 times or infinitely many times, writing the same byte every time. Actually, maybe it'll execute once and then throw an ArrayIndexOutOfBoundsException. That's basic java looping, and you're going to need a firm grip on that before you try to do anything as advanced as PDF reading. the case.oops you are absolutely right that was a silly mistake to forget that,
    Second, what do the docs for getPageContent say? Do they say that it simply gives you the text on the page as if the thing were a simple text doc? I'd be surprised if that's the case.getPageContent return array of bytes so the question will be:
    how to get text from this array? i was thinking of :
        private void jButton1_actionPerformed(ActionEvent e) {
            PdfReader read;
            StringBuffer buff=new StringBuffer();
            try {
                read = new PdfReader("d:/getjobid2727.pdf");
                read.getMetaData();
                byte[] data=read.getPageContent(1);
                int i=0;
                while(i>-1){ 
                    buff.append(data);
    i++;
    String str=buff.toString();
    FileOutputStream fos = new FileOutputStream("D:/test.txt");
    Writer out = new OutputStreamWriter(fos, "UTF8");
    out.write(str);
    out.close();
    read.close();
    } catch (Exception f) {
    f.printStackTrace();
    "D:/test.txt"  hasn't been created!! when i ran the program,
    is my steps right?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to retrieve IndividualStrings from a txt file using String Tokenizer.

    hello can any one help me to retrieve the individual strings from a txt file using string tokenizer or some thing like that.
    the data in my txt file looks like this way.
    Data1;
    abc; cder; efu; frg;
    abc1; cder2; efu3; frg4;
    Data2
    sdfabc; sdfcder; hvhefu; fgfrg;
    uhfhabc; gffjcder; yugefu; hhfufrg;
    Data3
    val1; val2; val3; val4; val5; val6;
    val1; val2; val3; val4; val5; val6;
    val1; val2; val3; val4; val5; val6;
    val1; val2; val3; val4; val5; val6;
    i need to read the data as an individual strings and i need to pass those values to diffarent labels,the dat in Data3 i have to read those values and add to an table datamodel as 6 columns and rows depends on the data.
    i try to retrieve data using buffered reader and inputstream reader,but only the way i am retrieving data as an big string of entire line ,i tried with stringtokenizer but some how i was failed to retrive the data in a way i want,any help would be appreciated.
    Regards,

    Hmmm... looks like the file format isn't even very consistent... why the semicolon after Data1 but not after Data2 or Data3??
    Your algorithm is reading character-by-character, and most of the time it's easier to let a StringTokenizer or StreamTokenizer do the work of lexical analysis and let you focus on the parsing.
    I am also going to assume your format is very rigid. E.g. section Data1 will ALWAYS come before section Data2, which will come before section Data3, etc... and you might even make the assumption there can never be a Data4, 5, 6, etc... (this is why its nice to have some exact specification, like a grammar, so you know exactly what is and is not allowed.) I will also assume that the section names will always be the same, namely "DataX" where X is a decimal digit.
    I tend to like to use StreamTokenizer for this sort of thing, but the additional power and flexibility it gives comes at the price of a steeper learning curve (and it's a little buggy too). So I will ignore this class and focus on StringTokenizer.
    I would suggest something like this general framework:
    //make a BufferedReader up here...
    do
      String line = myBufferedReader.readLine();
      if (line!=null && line.trim().length()>0)
        line = line.trim();
        //do some processing on the line
    while (line!=null);So what processing to do inside the if statement?
    Well, you can recognize the DataX lines easily enough - just do something like a line.startsWith("Data") and check that the last char is a digit... you can even ignore the digit if you know the sections come in a certain order (simplifying assumptions can simplify the code).
    Once you figure out which section you're in, you can parse the succeeding lines appropriately. You might instantiate a StringTokenizer, i.e. StringTokenizer strtok = new StringTokenizer(line, ";, "); and then read out the tokens into some Collection, based on the section #. E.g.
    strtok = new StringTokenizer(line, ";, ");
    if (sectionNo==0)
      //read the tokens into the Labels1 collection
    else if (sectionNo==1)
      //read the tokens into the Labels2 collection
    else //sectionNo must be 2
      //create a new line in your table model and populate it with the token values...
    }I don't think the delimiters are necessary if you are using end-of-line's as delimiters (which is implicit in the fact that you are reading the text out line-by-line). So the original file format you listed looks fine (except you might want to get rid of that rogue semicolon).
    Good luck.

Maybe you are looking for