forked from columbia-applied-data-science/rosetta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dkrasner
committed
Nov 10, 2013
1 parent
b13b5e0
commit c0b10bd
Showing
44 changed files
with
6,233 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,17 +9,17 @@ likelihood of your contribution being merged.** | |
How to contribute | ||
----------------- | ||
|
||
The preferred way to contribute to dspy is to fork the | ||
[project repository](https://github.com/columbia-applied-data-science/dspy/) on | ||
The preferred way to contribute to rosetta is to fork the | ||
[project repository](https://github.com/columbia-applied-data-science/rosetta/) on | ||
GitHub: | ||
|
||
1. Fork the [project repository](https://github.com/columbia-applied-data-science/dspy/): | ||
1. Fork the [project repository](https://github.com/columbia-applied-data-science/rosetta/): | ||
click on the 'Fork' button near the top of the page. This creates | ||
a copy of the code under your account on the GitHub server. | ||
|
||
2. Clone this copy to your local disk: | ||
|
||
$ git clone [email protected]:YourLogin/dspy.git | ||
$ git clone [email protected]:YourLogin/rosetta.git | ||
|
||
3. Create a branch to hold your changes: | ||
|
||
|
@@ -37,7 +37,7 @@ GitHub: | |
|
||
$ git push -u origin my-feature | ||
|
||
Finally, go to the web page of the your fork of the dspy repo, | ||
Finally, go to the web page of the your fork of the rosetta repo, | ||
and click 'Pull request' to send your changes to the maintainers for | ||
review. request. This will send an email to the committers. | ||
|
||
|
@@ -54,7 +54,7 @@ following rules before submitting a pull request: | |
example script in the ``examples/`` folder. Have a look at other | ||
examples for reference. Examples should demonstrate why the new | ||
functionality is useful in practice and, if possible, compare it | ||
to other methods available in dspy. | ||
to other methods available in rosetta. | ||
|
||
- At least one paragraph of narrative documentation with links to | ||
```` references in the literature (with PDF links when possible) and | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from rosetta.text.api import * |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Additions to your bashrc | ||
# | ||
# | ||
############################################################################### | ||
# INSTALLATION | ||
############################################################################### | ||
# Put desired sections in your ~/.bashrc (or ~/.bash_profile on macs) and then | ||
# "source it" or close then open a new terminal. | ||
# | ||
############################################################################### | ||
# Body function | ||
############################################################################### | ||
# This allows you to run a command on the body of the function, skipping the header | ||
# (but still printing the header). For example, | ||
# | ||
# $ cat filewithheader | body sort -k1,1 | ||
# | ||
# will sort filewithheader, using the first field, but leave the header at the top | ||
# of the file. | ||
|
||
body() { | ||
IFS= read -r header | ||
printf '%s\n' "$header" | ||
"$@" | ||
} | ||
|
||
export -f body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Concat a list of csv files in an "outer join" style. | ||
From pandas, uses DataFrame.from_csv, DataFrame.to_csv, concat to do | ||
reads/writes/joins. Except noted below, the default arguments are used. | ||
""" | ||
|
||
import argparse | ||
import sys | ||
|
||
import pandas as pd | ||
|
||
|
||
def _cli(): | ||
# Text to display after help | ||
epilog = """ | ||
EXAMPLES | ||
Concat two files, each with a header and index, redirect output to newfile | ||
$ python concat_csv.py --index --header file1 file2 > newfile | ||
Concat two files, write result to newfile | ||
$ python concat_csv.py --index --header -o newfile file1 file2 | ||
Concat all files in mydir/, write result to stdout. | ||
$ python concat_csv.py mydir/* | ||
""" | ||
parser = argparse.ArgumentParser( | ||
description=globals()['__doc__'], epilog=epilog, | ||
formatter_class=argparse.RawDescriptionHelpFormatter) | ||
|
||
parser.add_argument( | ||
'paths', nargs='*', help='Concat files in this space separated list') | ||
parser.add_argument( | ||
'-o', '--outfile', default=sys.stdout, | ||
type=argparse.FileType('w'), | ||
help='Write to OUT_FILE rather than sys.stdout.') | ||
parser.add_argument( | ||
'-s', '--sep', default=',', | ||
help='Delimiter to use. Regular expressions are accepted.' | ||
' [default: %(default)s]') | ||
|
||
parser.add_argument( | ||
'--index', action='store_true', default=False, | ||
help='Flag to set if files have an index (leftmost column).' | ||
' [default: %(default)s].') | ||
parser.add_argument( | ||
'--header', action='store_true', default=False, | ||
help='Flag to set if files have headers (in top row). ' | ||
'[default: %(default)s]') | ||
|
||
parser.add_argument( | ||
'-a', '--axis', type=int, default=0, | ||
help='Axes along which to concatenate') | ||
|
||
# Parse and check args | ||
args = parser.parse_args() | ||
|
||
# Call the module interface | ||
_concat( | ||
args.outfile, args.paths, args.sep, args.index, args.header, args.axis) | ||
|
||
|
||
def _concat(outfile, paths, sep, index, header, axis): | ||
# Read | ||
index_col = 0 if index else False | ||
header_row = 0 if header else False | ||
kwargs = {'sep': sep, 'index_col': index_col, 'header': header_row} | ||
frames = pd.concat( | ||
(pd.DataFrame.from_csv(p, **kwargs) for p in paths), axis=axis) | ||
|
||
# Write | ||
kwargs = {'sep': sep, 'index': index, 'header': header} | ||
|
||
frames.to_csv(outfile, **kwargs) | ||
|
||
|
||
if __name__ == '__main__': | ||
_cli() |
Oops, something went wrong.