Giter Site home page Giter Site logo

Comments (1)

AlejandraLLI avatar AlejandraLLI commented on September 21, 2024

El código anterior todavía tenía problemas con líneas que tenían información del tipo "< 5 minutes". El siguiente código ya soluciona esto.
function extract_table() {
# get table
sed -n '/<TABLE .>/,/</TABLE>/p' $1 |
# Fill non-responses with NA's
sed 's/
/NA/g' |
# Remove double NA's
sed 's/NANA//g' |
# Remove HTML code
sed 's/<[^<>]
>//g' |
# Remove ^M delimiters
sed 's/\r//g' |
# Remove empty lines
awk '/.+/ {print $0}' |
# Remove tabs
sed 's/\t/ /g' |
# Remove pipes
sed 's/|/ /g' |
# Add pipes to lines that should be the end of lines
awk '{if (NR %7 == 0) {print $0"|"} else {print $0}}' |
# Paste all lines together in one line with tabs as separator
sed -e :a -e '$!N; s/\n/\t/; ta' |
# Separate lines using the added pipe
sed 's/|/\n/g' |
# Remove tabs at the begining of the lines
sed 's/^\t//g' |
# Remove emplty lines.
awk '/.+/ {print $0}'
}

from programming-for-data-science-2019.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.