Reading specific part of a file

Hi
Im trying to design a java program that reads a txt file such as the one below:
0 400 450 510 670 493 958
1 500 560 630 5633
2 625 676 740
3 1000 1250 1600
4 432
5 2435 235 2654
Then through a user prompt, outputs a specific number from a specific line to the user, i.e.
Line 1
Column 3
Would print 450
i have little knowledge of java, and im not sure if i need to read the whole file into arrays or i can get java just to read a specific line and column from it
i have tried using arrays but as the txt file can be of any size it got confusing!
Please help!
Thanks to you all

jverd is right.. you can use string tokenizer to seperate the columns of data via spaces.. or whatever you wanna specify. I'm seriously bored, so I wrote a working example for you that uses the data you posted
import java.util.*;
import java.io.*;
// usage:
// java Example <line> <column>
public class Example {
     public Example(int line,int col) throws IOException {
          col++; // because StringTokenizer will also count the first number of the actual line
          // example.txt has the data you posted...
          BufferedReader b = new BufferedReader(new InputStreamReader(new FileInputStream("example.txt")));
          String s = "",data = "";
          int j;
          while ((s = b.readLine()) != null) {
               if (Integer.parseInt(""+s.charAt(0)) == line) { // matches line
                    StringTokenizer st = new StringTokenizer(s); // separates words by space character
                    if (st.countTokens() < col) {
                         System.out.println("invalid column for line "+line+". there are only "+(st.countTokens()-1)+" columns on this line.");
                         System.exit(0);
                    // skip to the column..
                    for (j = 0;j < col;j++) data = st.nextToken();
                    System.out.println(data);
     public static void main(String[] args) {
          if (args.length < 2) System.out.println("use java Example <line> <column>");
          else try {
               new Example(Integer.parseInt(args[0]),Integer.parseInt(args[1]));
          catch (NumberFormatException e) {
               System.out.println("line and column need to be a number");
          catch (IOException e) {
               e.printStackTrace();
}

Similar Messages

  • How to read specific line in a file through UNIX shell script..

    Dear Friends,
    I have generated .ldt file under admin/import/US folder through FND_LOAD script for Download the responsibility.
    I registred Shell script (Host concurrent program) in Oracle apps. Now i want to read the file in speciific line which i was generated in admin/import/US folder through unix shell script. Please help me how to read specific line and the i want to replace that which i am going to read the specific line.
    Thanks in advance..
    Regards,
    Velu.

    Hi,
    Thanks for reply,
    My requirement i have to find the specific line in a file and find and replace needed word over there it's should happen programatically. i want to read specific line in a file Once complete find and replace the condition should exists. The loop will go to next file and read the same line in next file also do the same process upto how many files over there.i am doing through UNIX shell script. Please help me out to find the
    Your suggestion is highly appriciated.
    Thanks,
    Velu.

  • Read Specific value/Search Into file

    Hi i need a java code which read specific value from a file.
    Example:
    I have a text file named data.txt
    it contain :
    Customer Name :Sarwar
    Customer Id : 001
    Product Price :2000
    now how can i take values 001 and 2000 from the file data.txt and save them in a another text file named new_data.txt ?
    Can any one help me?

    Search Google for 'java file read'. Wanna write to a file? Search for 'java file write'. Ain't Google awesome?
    If you haven't already done so, I suggest you search www.amazon.com for a beginner book on Java that has good reviews. Its much more efficient to read a book on Java than spend countless hours trying to learn it through code examples found on the internet.

  • Cant read a part of  xml file using AS3

    Hi
    i can read everything from my xml file except a part that i can always get teh first items of each category (it will make more sence in a sec)
    So here is my xml
    [HTML]<?xml version="1.0" encoding="UTF-8"?>
    <flashxml>
      <second_page>
        <sp text="ss ptextj"/>
        <ss text="sptext"/>
        <clas text="clas"/>
      </second_page>
      <third_page>
        <ss>
          <category name="categor">
            <item>3333</item>
            <item>H4444</item>
            <item>etc etc etc </item>
          </category>
          <category name="security ">
            <item>SSL</item>
            <item>Hacke</item>
            <item>etc etc etc </item>
          </category>
        </ss>
        <sp>
          <category name="security a">
            <item>SSL lallalala</item>
            <item>Hacker</item>
            <item>etc etc etc </item>
          </category>
          <category name="onlin">
            <item>Hussle free</item>
            <item>Diafore</item>
            <item>etc etc 2 </item>
          </category>
        </sp>
        <classifieds>
          <category name="Best">
            <item>Additem1</item>
            <item>Additem2</item>
            <item>Additem3 </item>
          </category>
        </classifieds>
      </third_page>
    </flashxml>[/HTML]
    I am trying for each category in the xml to get the relevant items ...
    The problem is that if i try to read for e.g the second set of items for the second category of <sp> using a counter it throws a type error
    TypeError: Error #1010: A term is undefined and has no properties.
    at MethodInfo-1()
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/flash.net:URLLoader::onComplete()
    so the following works
    var itemslist:XMLList = xml.third_page.ss.category[0].item;  (it will always display the first items of the first category for all the categories
    so for instance for sp will always return even for the second category
    <item>SSL lallalala</item>
            <item>Hacker</item>
            <item>etc etc etc </item>
    but when i am using
    var itemslist:XMLList = xml.third_page.ss.category[i].item;
    i am getting the type error above TypeError: Error #1010 .. (no idea why)
    Any help will be much appreciated
    complete code ::
    pp.buttonMode = true;
    pp.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
    pp.addEventListener(MouseEvent.CLICK, onButtonOut);
    function onButtonOver(e:MouseEvent):void
    e.currentTarget.gotoAndPlay("a");
    var xmlString:URLRequest = new URLRequest("ev.xml");
    var xmlLoader:URLLoader = new URLLoader(xmlString);
    xmlLoader.addEventListener("complete", init);
    function init(event:Event):void{
      var xDoc:XMLDocument = new XMLDocument();
      xDoc.ignoreWhite = true;
      var animalsXML:XML = XML(xmlLoader.data);
       //var list:XML = XML(xml Loader.data);
    // trace (animalsXML);  //prints the xml
      //edooooooooooooooooooooooooooooooooooo
    var  xml = XML(xmlLoader.data); 
               trace ("XML File");  
           trace ("===================");  
               trace (xml.second_page.sp.attribute("text"));   
          trace (xml.second_page.ss.attribute("text"));   
          trace (xml.second_page.clas.attribute("text"));   
      //edoooooooooooooooooooooooooooooooooooooooooooooooooooo
    // Third page ss
       var i = 0;
       var categorylist:XMLList = xml.third_page.ss.category;  
              for each (var captionElement:XML in categorylist)  
         i++;
                   trace (captionElement.attribute("name")); 
        //trace (captionElement.item);
        var itemslist:XMLList = xml.third_page.ss.category[0].item;
        for each (var captionElement:XML in itemslist)  
                    trace(captionElement);
      // trace (valueOf(captionElement.item));
    // Third page sp
       var i = 0;
       var categorylist:XMLList = xml.third_page.sp.category;  
              for each (var captionElement:XML in categorylist)  
         i++;
                   trace (captionElement.attribute("name")); 
        //trace (captionElement.item);
        var itemslist:XMLList = xml.third_page.sp.category[0].item;
        for each (var captionElement:XML in itemslist)  
                    trace(captionElement);
      // trace (valueOf(captionElement.item));
    // Third page clas
      var i = 0;
       var categorylist:XMLList = xml.third_page.classifieds.category;  
              for each (var captionElement:XML in categorylist)  
    i++;
               trace (i);
         trace (captionElement.attribute("name"));
        //   trace (captionElement.item);
      // trace (valueOf(captionElement.item));
        //var hi= captionElement.attribute("name");
    var itemslist:XMLList = xml.third_page.classifieds.category[0].item;
        for each (var captionElement:XML in itemslist)  
                    trace(captionElement);
      // trace (valueOf(captionElement.item));
      for each(var itemData:XML in animalsXML.elements()) {
    //  trace(itemData.elements().attribute("text")); //DOULEUI
    //third page
    //itemData.thirdpage.elements()[0].@patty
      xDoc.parseXML(animalsXML.toXMLString());
    // trace(xDoc.firstChild.childNodes[0]); //Riverside
      //trace(xDoc.firstChild.childNodes[0].nodeValue);
    //trace(xDoc.valueOf(.getElementsByTagName("item")[0].childNodes[0].nodeValue);
    function onButtonOut(e:MouseEvent):void
    e.currentTarget.gotoAndPlay("b");
    pb.gotoAndPlay("a");

    use
    var itemslist:XMLList = captionElement.item;
    instead of
    var itemslist:XMLList = xml.third_page.sp.category[0].item;
    that should work. You already got the category node in your captionElement variable, why not just use it instead of looking it up again in the document tree?

  • Reading a part of a file

    Hello, do you know if this is possible (doesn't matter what language..):
    If I have a big file which is much larger that my memory + swap space, say 20gb. Is it possible to say something like read the part from  the 1132312 byte to the 2132312 byte into memory. And than in memory having the option to do normal things like it was a normal file like reading it from the begin to then end byte by byte. Also is it possible to say something like replace the part from the 12312312 byte to the 22312312 byte with this that I have in memory?
    I only know of things like read write and append but as far as I know this is only possible with small files.
    Thanks in advance,
    David

    leeghoofd wrote:I only know of things like read write and append but as far as I know this is only possible with small files.
    In C and most lower level languages, opening a file requires something in the area of 2-3 pointers.  That's it.  The file handle and what's called a "file pointer" which contains the location.  You can use open(), seek(), and read() to get where you want are read the amount you want.

  • Read specification cluster from LVM file

    Does anyone have a clever solution to programmatically read limit specification masks (for waveform limit tests) from an LVM file?
    I used the "Mask and Limit Testing" Express VI to create the masks, which I saved as LVM using the save-data feature.
    I don't want to use the Express VI to do the actual test because the testing is in a subVI that's called within a loop; each iteration of the loop needs to send different masks to the Limit Test.vi that's in my subVI.
    Thanks,
    -a
    Solved!
    Go to Solution.

    Hi Andy,
     The LVM is a text file so you can read that in using read file function.
    After that I search the string to find where the data starts using Match Pattern
    You then process the remainder of the file string and then use Speadsheet String to Array with a tab as its delimiter. 
    There are tabs at the start of each line and extra line-feed at the end so I used array subset to avoid those areas. This might not work each time but you can fix that when you run into a problem.
    cheers
    David
    Message Edited by David Crawford on 11-05-2009 10:01 PM
    Attachments:
    Read Mask And Limit Checl LVM File.vi ‏13 KB
    Read Mask And Limit Checl LVM File.png ‏30 KB

  • Reading specific lines in a file

    hI
    i need to write a program which has a file name a.txt the contents in the file is
    SELECT DISTINCT D.MENUNAME, D.MENULABEL, D.MENUSEP, D.MENUORDER FROM PSMENUDEFN D, PSAUTHITEM A, PSOPRCLS C WHERE D.INSTALLED = 1 AND D.MENUGROUP = :1** AND D.MENUNAME = A.MENUNAME AND A.AUTHORIZEDACTIONS > 0 AND A.CLASSID = C.OPRCLASS AND C.OPRID = :2** ORDER BY D.MENUORDER, D.MENUNAME
    Bind-1 length=21 value=&Administer Workforce
    Bind-2 length=6 value=NLWAJP
    I need to read the file in such a way that in the SQL statement in the place of ":1" I need to get Bind-1 value i.e., &Administer Workforce and same with :2 I need to get Bind 2 value NLWAJP
    Output must be like this
    SELECT DISTINCT D.MENUNAME, D.MENULABEL, D.MENUSEP, D.MENUORDER FROM PSMENUDEFN D, PSAUTHITEM A, PSOPRCLS C WHERE D.INSTALLED = 1 AND D.MENUGROUP = &Adminster Workforce AND D.MENUNAME = A.MENUNAME AND A.AUTHORIZEDACTIONS > 0 AND A.CLASSID = C.OPRCLASS AND C.OPRID = NLWAJP ORDER BY D.MENUORDER, D.MENUNAME

    thomas.behr wrote:
    Read in your text file line by line, then replace \*XXX\*:Y** with the appropriate value using regular expressions.
    Phani532 wrote:The above answers doesnot answer my question....
    I am putting my question in refined format...Wrong. import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.StringReader;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    public class Test {
      private static final String DEFAULT_TEXT =
      "SELECT DISTINCT D.MENUNAME, D.MENULABEL, D.MENUSEP, D.MENUORDER FROM PSMENUDEFN D, PSAUTHITEM A, PSOPRCLS C WHERE D.INSTALLED = 1 AND *D.MENUGROUP = *:1** AND D.MENUNAME = A.MENUNAME AND A.AUTHORIZEDACTIONS > 0 AND A.CLASSID = C.OPRCLASS AND *C.OPRID = *:2** ORDER BY D.MENUORDER, D.MENUNAME\n" +
      "Bind-1 length=21 value=&Administer Workforce\n" +
      "Bind-2 length=6 value=NLWAJP";
      public static void main( String[] args ) {
        final List<String> lines = new ArrayList<String>();
        try {
          BufferedReader br = null;
          try {
            br = new BufferedReader(new StringReader(DEFAULT_TEXT));
            String line;
            while ((line = br.readLine()) != null) {
              lines.add(line);
          } finally {
            if (br != null) {
              br.close();
        } catch (IOException ioe) {
          lines.clear();
          ioe.printStackTrace();
        if (!lines.isEmpty()) {
          Collections.sort(lines, new Comparator<String>() {
            public int compare( final String s1, final String s2 ) {
              if (s1.startsWith("Bind-")) {
                if (s2.startsWith("Bind-")) {
                  return s1.compareTo(s2);
                } else {
                  return -1;
              } else {
                if (s2.startsWith("Bind-")) {
                  return 1;
                } else {
                  return s1.compareTo(s2);
          final Map<String, String> parameters = new HashMap<String, String>();
          for (String line : lines) {
            if (line.startsWith("Bind-")) {
              parameters.put(line.substring(5, line.indexOf(' ')), line.substring(line.indexOf("value=") + 6));
            } else if (line.startsWith("SELECT ")) {
              final Matcher matcher = Pattern.compile("\\*(.*?)\\*:([\\d]*?)\\*\\*").matcher(line);
              final StringBuilder sb = new StringBuilder();
              int last = 0;
              while (matcher.find()) {
                final int idx = matcher.start();
                if (idx > last) {
                  sb.append(line.substring(last, idx));
                sb.append(matcher.group(1));
                sb.append(parameters.get(matcher.group(2)));
                last = matcher.end();
              if (last < line.length()) {
                sb.append(line.substring(last));
              System.out.println(sb.toString());
    }(Lucky you, I'm feeling generous - and eager to code.)

  • Writing to Muliple Parts of a File

    Writing a large scale application that involves several threads that read different parts of a file, correct their respective part, and recreate the file.
    Is it possible for each of the threads to write to different parts of the same file simultaneously?
    Speed is an issue here so any tips would be helpful thanks.

    spacecadet,
    Succinctly. No.
    Use separate physical files for each working portion of the table. It's called striping. Google it.
    Any other brilliant ideas?

  • Can i remove a particular part of a file?

    I have a file. I want to remove a particular of that file. I have that Outputstream for that particular portion. How can i do it?
    Thanks

    use the bufferedinputstream to read the part of the file and write onto the same file using bufferedoutputstream or create a new file and write onto it.... simple.

  • Windows Cannot Access Specific Device, Path or File While Using Adobe Reader XI, Version 11.0.06

    Hello,
    Recently, I have been experiencing a minor problem with the Adobe Reader XI Program loaded on my computer.  When clicking the data fields on PDF versions of various forms to enter numerical or text information, a dialogue box with a small white X in a red circle on the left side of the title bar pops open and is titled:
    C:\Program Files\Common Files\microsoft shared\ink\TabTip.exe
    There is another white X in a red circle symbol displayed in the message field of the dialogue box along with the following message:
    Windows cannot access the specific device, path, or file.  You may not have the appropriate permissions to access the item.
    There is also an “OK” Button displayed on the right side of the lower margin of the dialogue box.
    Although the dialogue box is repeatedly displayed whenever I click on a data field, the program still allows me to enter and save the numerical and text information that is entered in each data field.
    My computer is a Hewlett-Packard Envy 23-d034 TouchSmart All-In-One Desktop Personal Computer with a Windows 8.1 Operating System that has all applicable Important and Recommended Windows Updates installed.  The Adobe Reader XI Program is the latest version, Version 11.0.06, and I have confirmed that there are no updates for the program at this time.
    Could you suggest any recommended actions to correct this problem with the Adobe Reader XI Program?

    unfortunately no. i have a problem in my computer that doesn't let me do that.
    this is  th entire message though and it appears on the background of the program trying to load. all you can see is the frame of Rreader, and immediatly after that it shuts down

  • Having trouble reading specific lines from a text file and displaying them in a listbox

    I am trying to read specific lines from all of the text files in a folder that are reports. When I run the application I get the information from the first text file and then it returns this error: "A first chance exception of type 'System.ArgumentOutOfRangeException'
    occurred in mscorlib.dll"
    Below is the code from that form. 
    Option Strict On
    Option Infer Off
    Option Explicit On
    Public Class frmInventoryReport
    Public Function ReadLine(ByVal lineNumber As Integer, ByVal lines As List(Of String)) As String
    Dim intTemp As Integer
    intTemp = lineNumber
    Return lines(lineNumber - 1)
    lineNumber = intTemp
    End Function
    Public Function FileMatches(ByVal folderPath As String, ByVal filePattern As String, ByVal phrase As String) As Boolean
    For Each fileName As String In IO.Directory.GetFiles(folderPath, filePattern)
    If fileName.ToLower().Contains(phrase.ToLower()) Then
    Return True
    End If
    Next
    Return False
    End Function
    Private Sub frmInventoryReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim intcase As Integer = 1
    Dim strTemp, strlist, strFile As String
    Dim blnCheck As Boolean = True
    strFile = "Report Q" & intcase.ToString & ".txt"
    Do While blnCheck = True
    strFile = "Report Q" & intcase.ToString & ".txt"
    Dim objReader As New System.IO.StreamReader("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\" & strFile)
    Dim allLines As List(Of String) = New List(Of String)
    Do While objReader.Peek <> -1
    allLines.Add(objReader.ReadLine())
    Loop
    objReader.Close()
    strlist = ReadLine(1, allLines) & "" & ReadLine(23, allLines)
    lstInventory.Items.Add(strlist)
    intcase += 1
    strTemp = intcase.ToString
    strFile = "Report Q" & intcase.ToString & ".txt"
    blnCheck = FileMatches("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\", "*.txt", intcase.ToString)
    Loop
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim intcase As Integer = 1
    Dim strTemp, strlist, strFile As String
    Dim blnCheck As Boolean = True
    strFile = "Report Q" & intcase.ToString & ".txt"
    Do While blnCheck = True
    strFile = "Report Q" & intcase.ToString & ".txt"
    Dim objReader As New System.IO.StreamReader("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\" & strFile)
    Dim allLines As List(Of String) = New List(Of String)
    Do While objReader.Peek <> -1
    allLines.Add(objReader.ReadLine())
    Loop
    objReader.Close()
    strlist = ReadLine(1, allLines) & "" & ReadLine(23, allLines)
    lstInventory.Items.Add(strlist)
    intcase += 1
    strTemp = intcase.ToString
    strFile = "Report Q" & intcase.ToString & ".txt"
    blnCheck = FileMatches("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\", "*.txt", intcase.ToString)
    Loop
    End Sub
    End Class
    Sorry I'm just beginning coding and I'm still a noob. Any help is appreciated. Thank you!

    Ok, so if I'm following this correctly you should be able to just loop through all of the files in that folder whose file name matches the pattern and then read the first 22 lines, recording only the first and the last.
    Exactly how you store the animal data probably depends on how you are going to display it and what else you are going to do with it.  Is there anything other than name and cage number that should be associated with each animal?
    You might want to make a dataset with a datatable to describe the animal, or you might write a class, or you might just use something generic like a Tuple.  Here's a simple class example:
    Public Class Animal
    Public Property Name As String
    Public Property Cage As String
    Public Overrides Function ToString() As String
    Return String.Format("{0} - {1}", Name, Cage)
    End Function
    End Class
    With that you can use a routine like the following to loop through all of the files and read each one:
    Dim animals As New List(Of Animal)
    Dim folderPath As String = "E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\"
    For Each filePath As String In System.IO.Directory.GetFiles(folderPath, "Report Q?.txt")
    Using reader As New System.IO.StreamReader(filePath)
    Dim lineIndex As Integer = 0
    Dim currentAnimal As New Animal
    While Not reader.EndOfStream
    Dim line As String = reader.ReadLine
    If lineIndex = 0 Then
    currentAnimal.Name = line
    ElseIf lineIndex = 22 Then
    currentAnimal.Cage = line
    Exit While
    End If
    lineIndex += 1
    End While
    animals.Add(currentAnimal)
    End Using
    Next
    'do something to display the animals list
    Then you might bind the animals list to a ListBox, or loop through the list and populate a ListView.  If you decided to fill a datatable instead of making Animal instances, then you might bind the resulting table to a DataGridView.
    There are lots of options depending on what you want and what all you need to do.
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • Reading a File by Knowing a part of the file name

    Hi Java Gurus,
    Can I copy a file to another location by knowing a part of the file name.I know the extension of the file and part of the file name.Can I copy such a file to another directory?
    Eg :
    0099999999_JAPPLIC_20090320.pdf is the file name.
    I know the file name contains 'JAPPLIC' .Can I use this clue and the extension of the file to copy the file to another directory.
    Please let me know whether it is possible or not.
    Regards,
    Rakesh.

    Hi ,
    I used the below code and I was able to solve the problem.I was able to select the files of the required extension and serach for the file names containing the text I know and use such files and move to another directory.It may be helpfulk to you people
    public class FileDeletion {
    public static void main (String args[]) {
         String e = "";
         String d = "C:\\TCCTouchpoints\\Attachments_Export\\outbound";
         String newFileLoc = "C:\\TCCTouchpoints\\Attachments_Export\\move";
    ExtensionFilter filter = new ExtensionFilter(e);
    File dir = new File(d);
    File newLoc = null;
    String[] list = dir.list(filter);
    if (list.length == 0) return;
    System.out.println("File Length "+list.length);
    ArrayList fileNames = new ArrayList();
    for (int i = 0; i < list.length; i++) {
    /*file = new File(d + list);
    boolean isdeleted = file.delete();
    System.out.print(file);
    System.out.println( " deleted " + isdeleted);*/
         System.out.println(list[i]);
         if(list[i].contains("_F5029.03_")){
              fileNames.add(list[i]);
              //System.out.println(list[i]);
    dir = null;
    for(int i=0;i<fileNames.size();i++){
         dir = new File(d+"\\"+fileNames.get(i));
         newLoc = new File(newFileLoc+"\\"+fileNames.get(i));
         if(dir.renameTo(newLoc)){
              System.out.println(dir + " is moved to "+ newLoc);
         }else {
              System.out.println("***** " dir " is not moved to "+ newLoc);
         dir = null; newLoc = null;
    for(int i=0;i<list.length;i++){
         dir = new File(d+"\\"+list[i]);
         dir.delete();
    class ExtensionFilter implements FilenameFilter {
    private String extension;
    public ExtensionFilter( String extension ) {
    this.extension = extension;
    public boolean accept(File dir, String name) {
    return (name.endsWith(extension));
    Thanks for replying .......

  • How to read a part of a TDMS file?

    Hi,
    I'm having problems loading back a part of a TDMS file.
    Im currently trying to use the offset and count input on TDMS read.
    But the offset value doesn't seem to make any difference: If I set offset to 5 and count to 10 it still puts out 10 data points.
    By the way:
    Im using labview 8.5, and I multiply the offset and count with the sample rate (100000samples/s) so that offset and count settings input will correspond to seconds of measurement to load.
    I would be very grateful for any help
    Regards
    Carl Zandén 
    Attachments:
    Load part of TDMS file.jpg ‏165 KB

    I am new to TDMS as well so take what I say with a grain (block) of salt.  But as no one else has answered, I'll give it a shot.  First of all, at 100000 S/s and an input for COUNT of 10 X 100000, you will always get 10 seconds worth of data.  Your graph is not showing you 10 data points, it is showing you 10 seconds OF data.  This is expected behavior.  By varying the OFFSET input as you have it you will step through your data 5 seconds (5 X 100000 points) at a time.  So, for IN offset =0 you will see data from 0 to 10 seconds, for IN offset =1 you will see data from 5 to 15 seconds, for IN offset =2 you will see data from 10 to 20 seconds, etc.  You also will probably NOT see the X scale change accordingly as it has no way to know what the initial time of your data set is, unless you tell it.  All it knows is that it has a set of 1M data points with a 1e-6 second delta t.
    Hope this helps.
    Roy

  • How to Read specific data from file and do a calculation and display on the output

    FYI: Below is the function use for the writing:
    -OpenFile(use ASCII)
    -sprintf
    -WriteFile
    Example: Output from the doc file
    …EndTime: 09:34:48 program time: 0.567663 sec
    …EndTime: 09:36:48 program time: 0.666666 sec
    My objective is to read data 0.666666 (FYI: is last sentence of the file) to do some calculation. How can we read specific data(specific location) from file..
    Any advice or help?
    What is the function needed?

    I would consider counting line feeds and checking for end-of file to isolate the last line, which then can be read using fscanf...
    Have a look at getc...
    character = fgetc ( stream );
    if ( character == '\n' ) // new line
    if ( character == EOF ) // end-of-file

  • Batch File to look at specific location in txt files

    Is there a way to have at batch file look at a specific line and location from a text file and pull it for use in the batch file?  For example, line 1 of sample.txt position ~15,8.
    I'm currently using the Find command(FIND /C "" *.TXT) but would like to be more specific in search.

    From a command line prompt, type 'help set' and look at environment variable expansion. Read the part that says "May also specify substrings for an expansion." It shows an example that uses ~10,5 to start at offset 10 and get the next 5 characters. Of course,
    this means that you will need to you will need to loop through each line. Use the FOR command; type 'help for' and start reading from "Some examples might help." It shows how you can parse a text file:
    FOR /F %%i IN (myfile.txt) do @echo %%i
    In a batch file, use two percent signs. At the command line, use one percent sign. 
    After the 'do' in the FOR command, you can use a CALL :Someprocedurename %%i, which would pass the line from the file into a sub and you can use the SET command to parse it.
    The Help mentions Command Extensions. At command prompt, type 'help setlocal' and read about ENABLEEXTENSIONS. At the bottom of the Help, they give you an example of how to add this to a batch file. You will need this to use the SET command to parse lines
    from the file.
    If you want to save the output, use the redirects, > or >> (create output file or append to output, respectively). Use the same for HELP output: help for > for-help.txt. In your line parser, you would do something more like this:
    [code]
    :ParseLine
    @echo %1 >> outputfile.txt
    exit /b
    GoTo :Eof
    [end code]
    To exit a sub, use either exit /b or goto :eof. Exit will allow you to return a value or error code. Goto :eof simply goes to end of file and returns control to the caller (in our case the FOR command). Of course, you can type 'help exit' to learn more.
    Outside of a subroutine, exit will end the batch file script and return to command prompt. This can be useful when you call this batch file from another script, but if you are starting it from Windows you may want to keep the command prompt open to show user
    the results or simply tell them to look at the output file.
    You can find good samples on Rob Van Der Woude's website.
    http://www.robvanderwoude.com/batchstart.php
    A major geek...

Maybe you are looking for

  • Why does my avi file get recognized on my windows 7 pc and not my 8.1?

    I have a windows 7 laptop that I've been working on a premiere file with, with one of the files included is an avi. I haven't had any issues. But I tried to open the same file on my surface tablet with 8.1, and got an error saying that the file is ei

  • Recovery question using archive log

    HPUX 11X Oracle 10.2.0.2 I have a standby database that the customers want to test the ability to fail over. They also want to test the data integrity of the standby once it's brought on line as the primary. I've already told the customer that any wr

  • How can I update my crashed iBook G4 to current or near-current software?

    My iBook G4 crashed last year, and I lost everything on it. Everything else updated except for iTunes. When trying to update iTunes, I'm only stuck at iTunes 4. Is there a way to try to update it to iTunes 7 [where I was before it crashed] or possibl

  • Capturing Motion Video and a SNAP with one CWIMAQ Device

    Hello, I am using Measurement Studio 6.0 controls and I am trying to accomplish a Continous Acquisition and a periodic interval SNAP Capture with only one CWIMAQ control. I have A CWIMAQ control attached to a 1 CWIMAQViewer this starts to acquire whe

  • Pass-parameter to query

    Hi guys, JDev Newbie here. I wish to make a 2 pagelayout. The main layout is composed of ex. single textbox. If the user pressed enter on that textbox, the 2nd pagelayout. The 2nd pagelayout will use the 1st page layout textbox value for query. How t