how can I sort a field form an Endnote Export File format where the Line contains GRAZ in the address as first line?

Walter Schrabmair

I have a Endote Export File, looking like this:

    %0 Journal Article
    %A Abu-Rous, M.
    %A Ingolic, E.
    %A Schuster, K. C.
    %D 2006
    %Z Cellulose
    Article
    CODEN: CELLE
    %+ Christian Doppler-Laboratory of Fibre and Textile Chemistry in Cellulosics, Institute of Texile Chemistry and Textile Physics, Leopold-Franzens-University Innsbruck, Hoechsterstrasse 73, A-6850 Dornbirn, Austria
    Research Institute for Electron Microscopy (FELMI), Technical University of Graz, A-8010 Graz, Austria
    Textile Innovation, Lenzing AG, A-4860 Lenzing, Austria
    Schuster, K.C.; Textile Innovation, , A-4860 Lenzing, Austria; email: [email protected]
    %~ Scopus
    %G English
    
    
    
    %0 Journal Article
    %P 5003-5011
    %! Ursolic acid from Trailliaedoxa gracilis induces apoptosis in medullary thyroid carcinoma cells
    %@ 17912997
    %R 10.3892/mmr.2015.4053
    %1 in_author_address; 
    %F 8
    %K Apoptosis
    Bioactive agents
    %Z Mol. Med. Rep.
    Article
    Chemicals/CAS: caspase 8; ursolic acid, 77-52-1; I kappa B kinase, 209902-66-9; Antineoplastic Agents, Phytogenic; Caspase 8; I-kappa B Kinase; IKBKG protein, human; Plant Extracts; Triterpenes; ursolic acid
    Tradenames: cpt, Sigma Aldrich; rotichrom, karlsruhe, Germany
    %+ Department of Pathophysiology and Immunology, Center of Molecular Medicine, Medical University of Graz, 31a Heinrichstrasse, Graz A, 8010, Austria
    Department of Biochemistry and Molecular Biology, Shanghai Medical School, Fudan University, Shanghai, 200433, China
    Department of Pharmacognosy, Institute of Pharmacy, Center of Molecular Biosciences, Leopold Franzens University of Innsbruck, Innsbruck A, 6010, Austria
    Core Unit of Biomedical Research, Division of Laboratory Animal Science and Genetics, Medical University of Vienna, Himberg A, 2325, Austria
    Research Institute for Electron Microscopy and Fine Structure Research, University of Technology Graz, Graz A, 8010, Austria
    Pfragner, R.; Department of Pathophysiology and Immunology, 31a Heinrichstrasse, Austria; email: [email protected]
    %~ Scopus C2 - 26151624
    %G English


    

the field beginning with %+ contains the Author Address which could consits of more lines according the author addresses (1 to n relationship) of the authors. Each authore address are separated by a newline (linebreak)

Now I would like to ask how I can sort this field by the lines where GRAZ are in the line. this lines where Graz are in it, they should be the first line in the listing.

Is there a way to do this by bash text processing tools, or need I write a Delphi`s programm to access and import the endnote Export dump.

The output of this example above should be

    %0 Journal Article
    %A Abu-Rous, M.
    %A Ingolic, E.
    %A Schuster, K. C.
    %D 2006
    %Z Cellulose
    Article
    CODEN: CELLE
    %+ Research Institute for Electron Microscopy (FELMI), Technical University of Graz, A-8010 Graz, Austria
    Christian Doppler-Laboratory of Fibre and Textile Chemistry in Cellulosics, Institute of Texile Chemistry and Textile Physics, Leopold-Franzens-University Innsbruck, Hoechsterstrasse 73, A-6850 Dornbirn, Austria
    Textile Innovation, Lenzing AG, A-4860 Lenzing, Austria
    Schuster, K.C.; Textile Innovation, , A-4860 Lenzing, Austria; email: [email protected]
    %~ Scopus
    %G English
    
    
    
    %0 Journal Article
    %P 5003-5011
    %! Ursolic acid from Trailliaedoxa gracilis induces apoptosis in medullary thyroid carcinoma cells
    %@ 17912997
    %R 10.3892/mmr.2015.4053
    %1 in_author_address; 
    %F 8
    %K Apoptosis
    Bioactive agents
    %Z Mol. Med. Rep.
    Article
    Chemicals/CAS: caspase 8; ursolic acid, 77-52-1; I kappa B kinase, 209902-66-9; Antineoplastic Agents, Phytogenic; Caspase 8; I-kappa B Kinase; IKBKG protein, human; Plant Extracts; Triterpenes; ursolic acid
    Tradenames: cpt, Sigma Aldrich; rotichrom, karlsruhe, Germany
    %+ Department of Pathophysiology and Immunology, Center of Molecular Medicine, Medical University of Graz, 31a Heinrichstrasse, Graz A, 8010, Austria
    Department of Biochemistry and Molecular Biology, Shanghai Medical School, Fudan University, Shanghai, 200433, China
    Department of Pharmacognosy, Institute of Pharmacy, Center of Molecular Biosciences, Leopold Franzens University of Innsbruck, Innsbruck A, 6010, Austria
    Core Unit of Biomedical Research, Division of Laboratory Animal Science and Genetics, Medical University of Vienna, Himberg A, 2325, Austria
    Research Institute for Electron Microscopy and Fine Structure Research, University of Technology Graz, Graz A, 8010, Austria
    Pfragner, R.; Department of Pathophysiology and Immunology, 31a Heinrichstrasse, Austria; email: [email protected]
    %~ Scopus C2 - 26151624
    %G English

I would be happy and thankful for any interesting advices.

tshiono

Would you please try the following:

#!/bin/bash

shopt -s nocasematch            # make the match case-insensitive

# print the arrays and empty them
flush() {
    printf "%s" "%+ "
    printf "%s\n" "${out1[@]}" "${out2[@]}"
    out1=(); out2=()
}

while IFS= read -r line; do     # read the file line by line
    if (( auth )); then         # now in the "Author Address" context
        if [[ $line = "%"* ]]; then
                                # end of the "Author Address" context
            auth=0
            flush               # print the arrays
            echo "$line"        # print current line
        else
            [[ $line = *"GRAZ"* ]] && out1+=("$line") || out2+=("$line")
                                # if the line contains "GRAZ" store it in the array out1, else out2
        fi
    else
        if [[ $line = "%+"* ]]; then
            auth=1              # enter in the "Author Address" context
            [[ $line = *"GRAZ"* ]] && out1+=("${line:3}") || out2+=("${line:3}")
                                # ${line:3} removes leading 3 characters
        else
            echo "$line"
        fi
    fi
done < input_file

Output:

%1 Journal Article
%A Abu-Rous, M.
%A Ingolic, E.
%A Schuster, K. C.
%D 2006
%Z Cellulose
Article
CODEN: CELLE
%+ Research Institute for Electron Microscopy (FELMI), Technical University of Graz, A-8010 Graz, Austria
Christian Doppler-Laboratory of Fibre and Textile Chemistry in Cellulosics, Institute of Texile Chemistry and Textile Physics, Leopold-Franzens-University Innsbruck, Hoechsterstrasse 73, A-6850 Dornbirn, Austria
Textile Innovation, Lenzing AG, A-4860 Lenzing, Austria
Schuster, K.C.; Textile Innovation, , A-4860 Lenzing, Austria; email: [email protected]
%~ Scopus
%G English



%0 Journal Article
%P 5003-5011
%! Ursolic acid from Trailliaedoxa gracilis induces apoptosis in medullary thyroid carcinoma cells
%@ 17912997
%R 10.3892/mmr.2015.4053
%1 in_author_address;
%F 8
%K Apoptosis
Bioactive agents
%Z Mol. Med. Rep.
Article
Chemicals/CAS: caspase 8; ursolic acid, 77-52-1; I kappa B kinase, 209902-66-9; Antineoplastic Agents, Phytogenic; Caspase 8; I-kappa B Kinase; IKBKG protein, human; Plant Extracts; Triterpenes; ursolic acid
Tradenames: cpt, Sigma Aldrich; rotichrom, karlsruhe, Germany
%+ Department of Pathophysiology and Immunology, Center of Molecular Medicine, Medical University of Graz, 31a Heinrichstrasse, Graz A, 8010, Austria
Research Institute for Electron Microscopy and Fine Structure Research, University of Technology Graz, Graz A, 8010, Austria
Pfragner, R.; Department of Pathophysiology and Immunology, 31a Heinrichstrasse, Austria; email: [email protected]
Department of Biochemistry and Molecular Biology, Shanghai Medical School, Fudan University, Shanghai, 200433, China
Department of Pharmacognosy, Institute of Pharmacy, Center of Molecular Biosciences, Leopold Franzens University of Innsbruck, Innsbruck A, 6010, Austria
Core Unit of Biomedical Research, Division of Laboratory Animal Science and Genetics, Medical University of Vienna, Himberg A, 2325, Austria
%~ Scopus C2 - 26151624
%G English

The output slightly differs from your expected output, one is because the ... University of Technology Graz ... line comes later than other lines which do not contain GRAZ in your expected result, the other is because medunigraz is considered to match GRAZ.

Este artículo se recopila de Internet, indique la fuente cuando se vuelva a imprimir.

En caso de infracción, por favor [email protected] Eliminar

Editado en
0

Déjame decir algunas palabras

0Comentarios
Iniciar sesiónRevisión de participación posterior

Artículos relacionados

How can I check if a line in a file has information or not in Python 3.6?

How can i cast the .nth() line in a file as an integer?

How can I use File.AppendAllText and add to it a new line?

How to add first line and last line value into existing XML file

How to skip the first line of a CSV file and make the second line the header

How can I switch the position of a line with the line after it in a text file using a Scanner?

How Would I Check if a Text File Contains Specified Text and Report what Line it is At

How Would I Check if a Text File Contains Specified Text and Report what Line it is At

I'm trying to solve this Python exercise but I have no idea of how to do it: get first character of a line from a file + length of the line

How can I sort list lines by time if the times are in different locations in the line?

how can i map the string that are in the object where empty string considered as empty line and each string restricted to one line

How to print the whole line that contains a specified byte offset in a file?

How do I read the last line of a file?

When I write to a file in C it writes in different lines. How can I write it in one line?

How can I make the line turn?

How can I suppress (not print) line numbers?

How can I fit a nonlinear line in R?

Format of a VBP File reference line

Go to first line in a file in vim?

How to format a multi line string with triple quotes inside in JSON file?

How do I loop though a text file, line by line, and append each line to an array?

awk field separator not working for first line

Align form field and submit button on same line

How to make first line of text file as header and skip second line in spark scala

Regex: How to insert text before the first line and after the last line of file

How to add new string/line below certain line in file which contains multiple same lines throughout a file in BASH?

How can I sort POSIXct datetime format in R?

How can I link the current Google Doc to a new Google Doc named with the text on the line where the cursor is currently located?

How to replace a string in a file only if the line containing it also contains a number found in another file using Bash?

TOP Lista

CalienteEtiquetas

Archivo