"[SOLVED] Importing: text with fixed length attributes"

UgoUgo MemberPosts:20Contributor II
edited June 2019 inHelp
Hello,

I have looked through the import components and Googled but cannot find a way to
read in a simple text file with fixed length attributes. How can one do this?

Apologies if this is a "no brainer" but I could not find a simple direct way to do this.

TIA,
Hugo

Answers

  • SkirzynskiSkirzynski MemberPosts:164Maven
    Hey,

    You probably need the "Read CSV" operator. This operator can read a structured data set from a text file. Use the wizard to import and configure this operator correctly. For instance it is important to specify the separator so the operator knows where the value for an attribute begins and stops.

    Best regards
    Marcin
  • UgoUgo MemberPosts:20Contributor II
    Hi Marcin,

    I already had a look at the CSV reader but it requires the use of a delimiter.
    The file I have has no such delimiters. As an example, assume I have a line:

    AABBCCCC

    In this case I have 3 attributes with lengths 2, 2 and 3 respectively.
    The attribute value would be AA, BB and CCCC. Note that no separator
    exists.

    Write now I am preparing AWK scripts to deal with this but I assumed
    Rapidminer can deal with this type of data easily.

    Thanks for the feedback.



  • awchisholmawchisholm RapidMiner Certified Expert, MemberPosts:458Unicorn
    Hello

    You could read the text file using the regular expression "\r\n" to read each complete line.

    Then use the operator Generate Extract to split each line into the required components using regular expressions.

    Here's an example





















    < =“query_type”价值=参数的关键"Regular Expression"/>



















    The text file contains this
    AABBCCCC
    ABCDBBDS
    ABDBQBDD
    AASHHFGU
    and the result looks like this
    a1 a2 a3
    AA BBC CCC
    AB CDB BDS
    AB DBQ BDD
    AA SHH FGU
    regards

    Andrew
  • UgoUgo MemberPosts:20Contributor II
    Hi Andrew,

    Exactly what I was looking for.

    Thank you.
    Hugo F.
Sign InorRegisterto comment.