Forum FlexPro – Discuss your topic!

Import Filter

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #12431

    Hallo,
    ich möchte folgende Datei importieren.

    ABC 450/10 D4
    870.61700.01
    17.05.2005
    RECHTS
    42.4
    33.5
    3.7
    3.690157565
    0.6520835066
    -0.0029605108
    9.854234017E-05
    6070
    6069.946104
    -205.1686329
    2.812642551
    -0.0316048779
    49.6

    Dies ist allerdings nur als Zeichnkette möglich, da sonst die Buchstaben und Wörter weggelassen und die Kennziffern (z.B. in Zeile 2) ebenfalls als Dezimalzahlen interpretiert werden.
    Da ich mit einem Teil der Zahlen danach weiterrechnen möchte, müsste ich diese anschließend als Fließkommazahlen umformatieren. Bei diesem Vorgang übernimmt das Programm allerdings nur die Ziffern vor dem Komma, die Dezimalstellen werden einfach gelöscht.
    Wie kann ich meine Datei importieren, so dass meine Zahlen auch als solche erkannt werden, der Rest jedoch unverändert übernommen wird?

    Des Weiteren möchte ich den Import automatisieren und als Makro aufnehmen.
    Gibt es eine Möglichkeit ein Makro so zu erstellen, dass ich nicht die einezelnen Schritte des Imports durchgehen muss, sondern meine Datei direkt und automatisch in das Programm importiert erhalte?

    Vielen Dank

    #8723
    Bernhard KantzBernhard Kantz
    Participant

    Each column in a file will result either in a separate dataset or will be part of a signal. This means that each column can have only one data type. FlexPro detects the data type automatically from the first lines in the file. If these lines contain text the whole column will be – suggested to be – imported as strings.
    If you import the data as text and convert it then back to floating point values conversion takes place regarding to the systems locale settings. For Germany this means that the decimal separator is assumed as ‘,’ not as ‘.’.
    That’s why you may lose the places after the decimal separator. If you do not like this you can either change the locale settings of your system or force FlexPro to use ‘.’ as decimal separator always (see DateiOptionen property page Ländereinstellungen).

    If you cannot skip the first four lines you will need to some VBA coding (this requires FlexPro Professional). The basic idea is like this:

    1. Open the text file in VBA.
    2. Create a TextDataLink object in the current folder.
    3. Read the first four lines and assign these values to the Name, Unit, Parameters or other appropriate property of the TextDataLink object.
    4. Assign the necessary properties to the TextDataLink object, especially FilePath, LineFrom (= 5) etc.
    5. Call the Evaluate method on the TextDataLink object to execute the import and convert the object to a dataset

    Take a look at the ImportFilter example (ImportFilter.FPD) for a sample import filter of a custom binary format. This example can be easily modified to fit your needs. The only difference is that you are using text files. If you transform the import filter sample and your files have either a custom extension or can be detected by your custom ImportSpy method you can import the files just as if using a built-in import filter.

    Support
    support@weisang.com

    #8112

    Hallo,
    ich möchte folgende Datei importieren.

    ABC 450/10 D4
    870.61700.01
    17.05.2005
    RECHTS
    42.4
    33.5
    3.7
    3.690157565
    0.6520835066
    -0.0029605108
    9.854234017E-05
    6070
    6069.946104
    -205.1686329
    2.812642551
    -0.0316048779
    49.6

    Dies ist allerdings nur als Zeichnkette möglich, da sonst die Buchstaben und Wörter weggelassen und die Kennziffern (z.B. in Zeile 2) ebenfalls als Dezimalzahlen interpretiert werden.
    Da ich mit einem Teil der Zahlen danach weiterrechnen möchte, müsste ich diese anschließend als Fließkommazahlen umformatieren. Bei diesem Vorgang übernimmt das Programm allerdings nur die Ziffern vor dem Komma, die Dezimalstellen werden einfach gelöscht.
    Wie kann ich meine Datei importieren, so dass meine Zahlen auch als solche erkannt werden, der Rest jedoch unverändert übernommen wird?

    Des Weiteren möchte ich den Import automatisieren und als Makro aufnehmen.
    Gibt es eine Möglichkeit ein Makro so zu erstellen, dass ich nicht die einezelnen Schritte des Imports durchgehen muss, sondern meine Datei direkt und automatisch in das Programm importiert erhalte?

    Vielen Dank

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.