How to extract  different date format in text file

well, iam new for using regex api(regular expression), In my project i want to extract the different format of date from the text file... date format will be 3rd june 2004, 03-06-2004, june 3rd and so on....
can any body give me regular expression to extract the date from the text file...
i will be very grateful..
kareem

date format will be 3rd june 2004, 03-06-2004, june 3rd and so on....The only way to do this (without implementing a "mind reader") is to determine in advance all the possible date formats that are possible in your input, and try to interpret each date using each of those formats until one of them passes.
It's easy enough to handle june 3rd vs 3 june vs 3rd june, but 6/3 vs 3/6, of course, is ambiguous.

Similar Messages

  • How can I use Automator to extract specific Data from a text file?

    I have several hundred text files that contain a bunch of information. I only need six values from each file and ideally I need them as columns in an excel file.
    How can I use Automator to extract specific Data from the text files and either create a new text file or excel file with the info? I have looked all over but can't find a solution. If anyone could please help I would be eternally grateful!!! If there is another, better solution than automator, please let me know!
    Example of File Contents:
    Link Time =
    DD/MMM/YYYY
    Random
    Text
    161 179
    bytes of CODE    memory (+                68 range fill )
    16 789
    bytes of DATA    memory (+    59 absolute )
    1 875
    bytes of XDATA   memory (+ 1 855 absolute )
    90 783
    bytes of FARCODE memory
    What I would like to have as a final file:
    EXCEL COLUMN1
    Column 2
    Column3
    Column4
    Column5
    Column6
    MM/DD/YYYY
    filename1
    161179
    16789
    1875
    90783
    MM/DD/YYYY
    filename2
    xxxxxx
    xxxxx
    xxxx
    xxxxx
    MM/DD/YYYY
    filename3
    xxxxxx
    xxxxx
    xxxx
    xxxxx
    Is this possible? I can't imagine having to go through each and every file one by one. Please help!!!

    Hello
    You may try the following AppleScript script. It will ask you to choose a root folder where to start searching for *.map files and then create a CSV file named "out.csv" on desktop which you may import to Excel.
    set f to (choose folder with prompt "Choose the root folder to start searching")'s POSIX path
    if f ends with "/" then set f to f's text 1 thru -2
    do shell script "/usr/bin/perl -CSDA -w <<'EOF' - " & f's quoted form & " > ~/Desktop/out.csv
    use strict;
    use open IN => ':crlf';
    chdir $ARGV[0] or die qq($!);
    local $/ = qq(\\0);
    my @ff = map {chomp; $_} qx(find . -type f -iname '*.map' -print0);
    local $/ = qq(\\n);
    #     CSV spec
    #     - record separator is CRLF
    #     - field separator is comma
    #     - every field is quoted
    #     - text encoding is UTF-8
    local $\\ = qq(\\015\\012);    # CRLF
    local $, = qq(,);            # COMMA
    # print column header row
    my @dd = ('column 1', 'column 2', 'column 3', 'column 4', 'column 5', 'column 6');
    print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
    # print data row per each file
    while (@ff) {
        my $f = shift @ff;    # file path
        if ( ! open(IN, '<', $f) ) {
            warn qq(Failed to open $f: $!);
            next;
        $f =~ s%^.*/%%og;    # file name
        @dd = ('', $f, '', '', '', '');
        while (<IN>) {
            chomp;
            $dd[0] = \"$2/$1/$3\" if m%Link Time\\s+=\\s+([0-9]{2})/([0-9]{2})/([0-9]{4})%o;
            ($dd[2] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of CODE\\s/o;
            ($dd[3] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of DATA\\s/o;
            ($dd[4] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of XDATA\\s/o;
            ($dd[5] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of FARCODE\\s/o;
            last unless grep { /^$/ } @dd;
        close IN;
        print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
    EOF
    Hope this may help,
    H

  • How do you read data from a text file into a JTextArea?

    I'm working on a blogging program and I need to add data from a text file named messages.txt into a JTextArea named messages. How do I go about doing this?

    Student_Coder wrote:
    1) Read the file messages.txt into a String
    2) Initialize messages with the String as the textSwing text components are designed to use Unix-style linefeeds (\n) as line separators. If the text file happens to use a different style, like DOS's carriage-return+linefeed (\r\n), it needs to be converted. The read() method does that, and it saves the info about the line separator style in the Document so the write() method can re-convert it.
    lethalwire wrote:
    They have 2 different ways of importing documents in this link:
    http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
    Neither of those methods applies to JTextAreas.

  • How can I plott data from a text file in the same way as a media player using the pointer slide to go back and fort in my file?

    I would like to plott data from a text file in the same way as a media player does from a video file. I’m not sure how to create the pointer slide function. The vi could look something like the attached jpg.
    Please, can some one help me?
    Martin
    Attachments:
    Plotting from a text file like a media player example.jpg ‏61 KB

    HI Martin,
    i am not realy sure what you want!?!?
    i think you want to display only a part of the values you read from XYZ
    so what you can do:
    write all the values in an array.
    the size of the array is the max. value of the slide bar
    now you can select a part of the array (e.g. values from 100 to 200) and display this with a graph
    the other option is to use the history function of the graphes
    regards
    timo

  • How to do import data from the text file into the mathscript window?

    Could anyone tell me how to do import data from text file into mathscript window for labview 8?
    MathScript Window openned, File, Load Data - it has options: custom pattern (*.mlv) or all files. 
    Thanks

    Hi Milan,
    Prior to loading data in Mathscript Window , you have to save the data from the Mathscript window (the default extension of the file is .mlv but you can choose any extension). This means that you cannot load data from a text file  that was not created using the Mathscript window.
    Please let me know if you have any further questions regarding this issue.
    Regards,
    Ankita

  • How to load Test data from a Text file in ECATT

    Hi,
    I have created a test configuration with a test script, system data container, and test data container.
    I have done the recording of a transaction and created the script. Parameterization is done for the script and have imported those parameters from script in to the data container.
    I am trying to load a the data from a text file on the local work-station. The data is not being read.
    Please explain this in detail (step by step) as I am very new to ECATT.
    I am trying this on SAP ECC 6.0 IDES server.
    Thanks in Advance
    Vikas Patil

    Please explain this in detail (step by step) as I am very new to ECATT.
    Thanks in Advance
    Vikas Patil

  • How to automate loading data from a text file ?

    Hi,
    I need to load a data form a text file automatically. (for example: every day at 6.p.m) .
    It is possible to use DBMS_SCHEDULER with SQL LOADER ? or maybe u have others idea ?
    regards,

    assuming that the text file resides at the machine where the database is installed at you can create a procedure that use the built-in UTL_FILE package to read and load the data to the oracle tables. then create a job that use the DBMS_JOB or DBMS_SCHEDULER to create an automated schedule to run the job that calls the procedure you have created.
    or assuming that the text file resides or at the local/client machine (example c:\ drive) on a windows xp platform. create a batch file that do a ftp to transfer the text file to the oracle database server and create a schedule job using the windows scheduler. also create a procedure that use the built-in UTL_FILE package to read and load the data to the oracle tables. then create a job that use the DBMS_JOB or DBMS_SCHEDULER to create an automated schedule to run the job that calls the procedure you have created.

  • How to handle different date formats ?

    I'm currently writing an application that has to be compatible with different database backends.
    But I have some problems with the date/time fields when using Oracle as a db backend:
    After searching the forums, I found a solution for my "inserts" problem:
    // This is needed because otherwise the db session will be reset with each jdbc call,
    // ending the session and nullifying the ALTER SESSION command
    con.setAutoCommit( false );
    // set the date/time format to what we want it to be
    result = stmt.executeQuery("ALTER SESSION SET NLS_DATE_FORMAT = 'dd/mm/yyyy hh24:mi:ss'");
    res = stmt.executeUpdate(query);
    Where query is something like "INSERT INTO DATE_TEST VALUES ('val1',"val2','val3','25/03/2004 15:59:44');
    But when I want to retrieve this data, the timestamp is returned in another format:
    result = stmt.executeQuery("SELECT * FROM DATE_TEST");
    This gives me "2004-03-25 15:59:44.0" for the timestamp !
    when I run exactly the same query in the Oracle SQL*Plus console, I get the correct format:
    SQL> SELECT * FROM DATE_TEST;
    VAL1 VAL2 VAL3 TIME
    val1 val2 val3 25/03/2004 15:59:44
    SQL>
    I already tried the trick with the NLS_DATE_FORMAT before retrieving the data, but that doesn't seem to do anything.
    Any ideas how I can manipulate the format of a DATE field for retrieval ?
    Note:
    This is what I use:
    - Oracle 9i, Release 2 (9.2.0.1.0) for Windows (on windows 2000 Server)
    - ojdbc14.jar (Oracle thin jdbc driver)
    - j2sdk 1.4.2-04 for my application (currently running on windows server 2003 Enterprise, but is also tested on windows 2000, xp, linux, solaris)

    well, in fact I wrote a "dbAdapter" which I use to let my application communicate with a database.
    the method I use to retrieve data from the db just reads the resultset row by row, adding each row to a
    vector.
    each row is represented by a hashtable (colname - colvalue pairs).
    Vector result = dbadapter.queryDB("SELECT * FROM DATE_TEST");
    the method "query" looks like this:
    public Vector queryDB(String query) {
    Connection con = null;
    ResultSet result = null;
    ResultSetMetaData metadata = null;
    Vector tableData = new Vector();
    Statement stmt = null;
    try { // Attempt to load the JDBC driver with newInstance
    Class.forName(sDriver).newInstance();
    catch (Exception e) { // error
    logger.error(logPrefix + "Failed to load current driver.");
    if (psStackTrace != null)
    e.printStackTrace(psStackTrace);
    return tableData;
    } // end catch
    try {
    con = DriverManager.getConnection(sURL, sUsername, sPassword);
    // stmt = con.createStatement(); // MySQL
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); // TODO-ORACLE
    catch (Exception e) {
    logger.error(logPrefix + "problems connecting to " + sURL + ":" + e.getMessage());
    if (psStackTrace != null)
    e.printStackTrace(psStackTrace);
    if (con != null) {
    try {
    con.close();
    catch (Exception e2) {
    return tableData;
    } // end catch
    // execute SQL commands
    try {
    result = stmt.executeQuery(query);
    // first display some metadata
    metadata = result.getMetaData();
    int numcols = metadata.getColumnCount(); // How many columns?
    result.last(); // Move to last row
    int numrows = result.getRow();
    Hashtable rowData = new Hashtable();
    String colValue = "", colName = "";
    Object o = null;
    for (int a = 0; a < numrows; a++) {
    result.absolute(a + 1); // go to row a in resultset
    for (byte b = 0; b < numcols; b++) {
    o = result.getObject(b + 1);
    colName = metadata.getColumnName(b + 1);
    if (o == null) {
    colValue = "";
    else {
    colValue = o.toString();
    rowData.put(colName, colValue);
    tableData.add(rowData.clone());
    rowData.clear();
    // return result
    return tableData;
    catch (Exception e) {
    logger.error(logPrefix + "problem with SQL sent to " + sURL + ":" + e.getMessage());
    logger.debug(logPrefix + "sql: " + query);
    if (psStackTrace != null)
    e.printStackTrace(psStackTrace);
    finally {
    try {
    stmt.close();
    catch (Exception e) {
    try {
    con.close();
    catch (Exception e) {
    } // end finally clause
    return tableData;
    then I display the data using this code (output goes to a logfile):
    for (int i = 0; i < result.size(); i++) {
    Hashtable tmpResultTable = (Hashtable) result.elementAt(i);
    Enumeration enum = tmpResultTable.keys();
    while(enum.hasMoreElements()) {
    String tmpKey = (String) enum.nextElement();
    String tmpValue = (String) tmpResultTable.get(tmpKey);
    logger.debug(logPrefix + "\t- " + tmpKey + "=" + tmpValue);
    It is correct indeed that I want to keep it as vendor neutral as possible, because other databases will
    be added in the (near) future (such as IBM's DB2)
    I already thought about formatting it using the SimpleDateFormat class, but then I have to rewrite most
    of the code in my dbAdapter, because it doesn't know anything about the field types.
    It just launches standard SQL queries and returns the result back to the requesting object

  • How to retrieve specific data from a text file

    Hi, everyone
    For my project it is required that a parameter file is read at the beginning, in order for certain variables to be initialized with specific values that change with the user.
    At the moment, the way it is done is the following:  The values at a specified sequence in a text file are read and saved in an array and the elements of the array are retrieved according to their index.
    The problem with this implementation is, that if for some reason the format of the file changes, e.g. we want to use a parameter file from a previous version of the program that has the values for the same variables but in a different order, the only way to have the right values for the parameters is to change everything accordingly, which is really time wasting.
    Could someone suggest a different implementation that would make the reading of the different values independent from their order in the file, e.g. by scanning the file for specific strings and reading the value after the string?
    Thank you very much.
    P.S. I have  attached a screenshot of the routine I am using now.
    Solved!
    Go to Solution.
    Attachments:
    read parameter file.JPG ‏180 KB

    Hi panagiov,
    Find attached Folders.
    Method 1: in this you can search for each variable separately. You can use "Config file vis" to get all keys(Variables) at once and then you can use for loop to get their values. Or you can access individual values as shown in this code.
    Method 2: here you will get all data at once. You will get Variable and Data (2D array) You need to search variables as and when required.
    I hope you will understand these methods.
    Best of luck
    Gaurav k
    CLD Certified !!!!!
    Do not forget to Mark solution and to give Kudo if problem is solved.
    Attachments:
    Method 1.zip ‏7 KB
    Method 2.zip ‏9 KB

  • Extracting specific data from multiple text files to single CSV

    Hello,
    Unfortunately my background is not scripting so I am struggling to piece together a powershell script to achieve the below. Hoping an experienced powershell scripter can provide the answer. Thanks in advance.
    I have a folder containing approx. 2000 label type files that I need to extract certain information from to index a product catalog. Steps to be performed within the script as I see are:
    1. Search folder for *.job file types
    2. Search the files for certain criteria and where matched return into single CSV file
    3. End result should be a single CSV with column headings:
    a) DESCRIPTION
    b) MODEL
    c) BARCODE                                                                                                                   

    Try:
    # Script to extract data from .job files and report it in CSV
    # Sam Boutros - 8/24/2014
    # http://superwidgets.wordpress.com/category/powershell/
    $CSV = ".\myfile.csv" # Change this filename\path as needed
    $Folders = "d:\sandbox" # You can add multiple search folders as "c:\folder1","\\server\share\folder2"
    # End Data entry section
    if (-not (Test-Path -Path $CSV)) {
    Write-Output """Description"",""Model"",""Barcode""" | Out-File -FilePath $CSV -Encoding ascii
    $Files = Get-ChildItem -Path $Folders -Include *.job -Force -Recurse
    foreach ($File in $Files) {
    $FileContent = Get-Content -Path $File
    $Keyword = "viewkind4"
    if ($FileContent -match $Keyword) {
    for ($i=0; $i -lt $FileContent.Count; $i++) {
    if ($FileContent[$i] -match $Keyword) {
    $Description = $FileContent[$i].Split("\")[$FileContent[$i].Split("\").Count-1]
    } else {
    Write-Host "Keyword $Keyword not found in file $File" -ForegroundColor Yellow
    $Keyword = "Code:"
    if ($FileContent -match $Keyword) {
    for ($i=0; $i -lt $FileContent.Count; $i++) {
    if ($FileContent[$i]-match $Keyword) {
    $Parts = $FileContent[$i].Split(" ")
    for ($j=0; $j -lt $Parts.Count; $j++) {
    if ($Parts[$j] -match $Keyword) {
    $Model = $Parts[$j+1].Trim()
    $Model = $Model.Split("\")[$Model.Split("\").Count-1]
    } else {
    Write-Host "Keyword $Keyword not found in file $File" -ForegroundColor Yellow
    $Keyword = "9313"
    if ($FileContent -match $Keyword) {
    for ($i=0; $i -lt $FileContent.Count; $i++) {
    if ($FileContent[$i] -match "9313") {
    $Index = $FileContent[$i].IndexOf("9313")
    $Barcode = $null
    for ($j=0; $j -lt 12; $j++) {
    $Barcode += $FileContent[$i][($Index+$j)]
    } else {
    Write-Host "Keyword $Keyword not found in file $File" -ForegroundColor Yellow
    Write-Output "File: '$File', Description: '$Description', Model: '$Model', Barcode: '$Barcode'"
    Write-Output """$Description"",""$Model"",""$Barcode""" | Out-File -FilePath $CSV -Append -Encoding ascii
    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable)

  • Date Format in Text file

    Friends,
    I am generating a file through some script and need to add the date in front of it. I used cmd command and created a batch file but the format is coming as test.txt_12272013 but it should be Test.txt_20131227
       (YYYYMMDD)
    ren c:\testt\testing.txt test_%date:~4,2%%date:~7,2%%date:~10,4%.txt
    Could you guys please help

    Thank you Johnny. Actually I was looking for test_20121217.txt  (YYYYMMDD) format but i figured it out
    below is the string i had to use to get the YYYYMMDD format through DOS prompt
    _%date:~10,4%%date:~4,2%%date:~7,2%.txt

  • How to define the date format for this date string

    2006-11-13 00:00:00.0
    How to define the date format in control file for sqlldr. "yyyy-mm-dd hh24:mi:ss" or "yyyy-mm-dd hh24:mi:ss.FF1" does not work
    thanks,

    SQL> desc t
    Name                                      Null?    Type
    TS                                                 TIMESTAMP(6)
    SQL> !cat t.ctl
    load data
    into table t
    truncate
    (ts timestamp "YYYY-MM-DD HH24:MI:SS.FF1")
    SQL> !cat t.dat
    2006-11-13 00:00:00.0
    SQL> !sqlldr userid=scott/tiger control=t.ctl data=t.dat log=t.log
    SQL*Loader: Release 10.2.0.3.0 - Production on Fri Sep 7 11:19:28 2007
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Commit point reached - logical record count 1
    SQL> select * from t;
    TS
    13-NOV-06 12.00.00.000000 AMBest regards
    Maxim

  • Writing data to a text file in a java code

    hey,
    can anybody tell me how can i enter data into a text file using java code.
    thanx

    yeah this is the proper answer....
    i had also a pblm ..that i had to read data from an excel sheet and write it to a File thru java code ....
    u can also use FileOutPutStream object....if u want...
    but there u can give newLine()..so all ur output will be in a single line to the file....
    bufferWriter.write(stringToBeWritten);
    bufferWriter.newLine();
    the stringToBeWritten can be a hardCoded string value..or any dynamic value like say fetching from database...

  • Hi i am new to labview. i want to extract data from a text file and display it on the front panel. how do i proceed??

    Hi i am new to labview
    I want to extract data from a text file and display it on the front panel.
    How do i proceed??
    I have attached a file for your brief idea...
    Attachments:
    extract.jpg ‏3797 KB

    RoopeshV wrote:
    Hi,
    The below code shows how to read from txt file and display in the perticular fields.
    Why have you used waveform?
    Regards,
    Roopesh
    There are so many things wrong with this VI, I'm not even sure where to start.
    Hard-coding paths that point to your user folder on the block diagram. What if somebody else tries to run it? They'll get an error. What if somebody tries to run this on Windows 7? They'll get an error. What if somebody tries to run this on a Mac or Linux? They'll get an error.
    Not using Read From Spreadsheet File.
    Use of local variables to populate an array.
    Cannot insert values into an empty array.
    What if there's a line missing from the text file? Now your data will not line up. Your case structure does handle this.
    Also, how does this answer the poster's question?

  • How to extract Slide data in 3rd part application from clipboard

    I need to be able to copy/paste or drag/drop from PowerPoint into another application (C# WPF). In my OnDrop method the DragEventArgs Data has these formats:
            [0]    "Preferred DropEffect"    string
            [1]    "InShellDragLoop"    string
            [2]    "PowerPoint 12.0 Internal Slides"    string
            [3]    "ActiveClipBoard"    string
            [4]    "PowerPoint 14.0 Slides Package"    string
            [5]    "Embedded Object"    string
            [6]    "Link Source"    string
            [7]    "Object Descriptor"    string
            [8]    "Link Source Descriptor"    string
            [9]    "PNG"    string
            [10]    "JFIF"    string
            [11]    "GIF"    string
            [12]    "Bitmap"    string
            [13]    "System.Drawing.Bitmap"    string
            [14]    "System.Windows.Media.Imaging.BitmapSource"    string
            [15]    "EnhancedMetafile"    string
            [16]    "System.Drawing.Imaging.Metafile"    string
            [17]    "MetaFilePict"    string
            [18]    "PowerPoint 12.0 Internal Theme"    string
            [19]    "PowerPoint 12.0 Internal Color Scheme"    string
    The "PowerPoint 14.0 Slides Package" is a byte array... can this be converted into Slides?
    If not how would I go about getting high-resolution images + slide text from a drag/drop?
    [Originally posted here: http://answers.microsoft.com/en-us/office/forum/office_2013_release-powerpoint/how-to-extract-slide-data-in-3rd-part-application/a0b5ed64-eb77-49bb-bf44-e0732e23a5eb]

    What I'd like to do:
    Open PowerPoint
    In PPT open a presentation
    In PPT select a slide
    Drag it to my 3rd party WPF application
    In the 3rd party WPF application drop handler get the slide data (text, background image, etc...).
    When I do this I get the DragEventArgs Data (the clipboard data) and it has the 20 supported formats I listed in the 1st post. From these formats #4 seemed like it could have some useful info.
    WPF
    <Window x:Class="PowerPointDropSlide.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525" AllowDrop="True" Drop="UIElement_OnDrop" DragOver="UIElement_OnDragOver">
    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="LightBlue">
    <TextBlock Text="Drop something here!"/>
    </Grid>
    </Window>
    Handlers:
    public void UIElement_OnDragOver(object sender, DragEventArgs e)
    public void UIElement_OnDrop(object sender, DragEventArgs e)
    string[] supportedFormats = e.Data.GetFormats();
    object pptSlidesPackage = e.Data.GetData("PowerPoint 14.0 Slides Package");

Maybe you are looking for

  • Caller ID not working since i upgraded to IOS6

    Has anyone had trouble with Caller Id on the IOS6 upgrade on and iPhone 4s??

  • GR / IR and Price Differences

    Hi A question on price differences. We currently post our price differences at goods receipt (PO price - Std price). And secondly at invoice receipt (PO price - Actual price) In order to be able to analyze easier, we want to post goods receipts alway

  • How to move a rented movie from IPAD to Macbook Itunes?

    Hi, I've rented a movie and downloaded it on my IPAD4. I didn't watch it yet and I prefer to move the movie to my Macbook pro Itunes. I've connected the IPAD4 to the Macbook using the USB cable provided with the IPAD power supplier but I cannot find

  • Os command for ftp server

    I use file adapter receiver channel to transfer messages to external ftp servers. After a file is transported to the ftp server completely, I need to run a OS command to rename the file accordingly. My question is where I should put the OS command fi

  • How to update master pay data in HR using ABAP

    Hi, My requirement is that I need to update the master pay data for all the employees. The pay scale has been revised and so the pay scale needs to be changed. This means that the configuration needs to be done. Once this config is done, the pay scal