Shell script to parse CSV to an XML query?

前端 未结 2 747
挽巷
挽巷 2020-12-12 03:19

I have a list of citations in a csv file that I would like to use to fill out the XML based query form at CrossRef

CrossRef provides an XML template (below, with unu

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 04:15

    #!/usr/bin/awk -f
    # XML Attributes Must be Quoted. Attribute values must always be quoted. Either single or double quotes can be used.
    
    BEGIN{
        FS=","
        print ""
        print ""
        print ""
        print "   test@crossref.org"
        print "   test"
        print ""
        print ""
    }
    
    NR>1{
        print "  "
        print "    " $3 ""
        print "    " $1 ""
        print "    " $5 ""
        print "    " $2 ""
        print "    " $6 ""
        print "    " $4 ""
        print "  "
    }
    
    END{
        print ""
        print ""
    }
    

    $ awk -f script.awk input.csv
    

提交回复
热议问题