Skip to content

Commit

Permalink
change header file name
Browse files Browse the repository at this point in the history
change header file name to start with a minus sign to make sure it comes up first in alphabetical order
  • Loading branch information
Tagar committed Nov 6, 2017
1 parent ac469f9 commit c0afd8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions abalon/spark/sparkutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def debug_print (message):
debug_print("Source directory {} removed.".format(src_dir))


def HDFSwriteString (dst_file, content, overwrite=True):
def HDFSwriteString (dst_file, content, overwrite=True, appendEOL=True):

"""
Creates an HDFS file with given content.
Expand All @@ -154,10 +154,14 @@ def HDFSwriteString (dst_file, content, overwrite=True):
:param dst_file: destination HDFS file to write to
:param content: string to be written to the file
:param overwrite: overwrite target file?
:param appendEOL: append new line character?
"""

out_stream = fs.create(hadoop.fs.Path(dst_file), overwrite)


if appendEOL:
content += "\n"

try:
out_stream.write(bytearray(content))
finally:
Expand Down Expand Up @@ -196,8 +200,8 @@ def dataframeToHDFSfile (dataframe, dst_file, overwrite=False,

if header:
# we will create a separate file with just a header record
header_record = delimiter.join(dataframe.columns) + '\n'
header_filename = "{}/__00_header.csv".format(dst_dir) # have to make sure header filename is 1st in
header_record = delimiter.join(dataframe.columns)
header_filename = "{}/--00_header.csv".format(dst_dir) # have to make sure header filename is 1st in
# alphabetical order
HDFSwriteString(header_filename, header_record)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# http://setuptools.readthedocs.io/en/latest/setuptools.html

setup(name='abalon',
version='1.2.3',
version='1.3.0',
packages=find_packages(),

# install_requires=['docutils>=0.3'],
Expand Down

0 comments on commit c0afd8c

Please sign in to comment.