mirror of
https://github.com/taers232c/GAMADV-XTD3.git
synced 2025-12-10 13:45:02 -06:00
Added option transpose [<Boolean>] to redirect csv
This commit is contained in:
parent
46d1267ddb
commit
9004489e8a
@ -102,7 +102,7 @@ If an item contains spaces, it should be surrounded by ".
|
|||||||
banana|basil|blueberry|flamingo|graphite|grape|
|
banana|basil|blueberry|flamingo|graphite|grape|
|
||||||
lavender|peacock|sage|tangerine|tomato
|
lavender|peacock|sage|tangerine|tomato
|
||||||
<FileFormat> ::=
|
<FileFormat> ::=
|
||||||
csv|doc|dot|docx|dotx|epub|html|jpeg|jpg|mht|odp|ods|odt|
|
csv|doc|dot|docx|dotx|epub|html|jpeg|jpg|json|mht|odp|ods|odt|
|
||||||
pdf|png|ppt|pot|potx|pptx|rtf|svg|tsv|txt|xls|xlt|xlsx|xltx|zip|
|
pdf|png|ppt|pot|potx|pptx|rtf|svg|tsv|txt|xls|xlt|xlsx|xltx|zip|
|
||||||
ms|microsoft|openoffice|
|
ms|microsoft|openoffice|
|
||||||
<LabelColorHex> ::=
|
<LabelColorHex> ::=
|
||||||
@ -1276,8 +1276,8 @@ If the pattern {{Section}} appears in <FileName>, it will be replaced with the n
|
|||||||
For redirect csv, the optional arguments must appear in the order shown.
|
For redirect csv, the optional arguments must appear in the order shown.
|
||||||
<Redirect> ::=
|
<Redirect> ::=
|
||||||
redirect csv <FileName> [multiprocess] [append] [noheader] [charset <Charset>]
|
redirect csv <FileName> [multiprocess] [append] [noheader] [charset <Charset>]
|
||||||
[columndelimiter <Character>] [noescapechar <Boolean>] [quotechar <Character>]
|
[columndelimiter <Character>] [noescapechar [<Boolean>]] [quotechar <Character>]
|
||||||
[sortheaders <StringList>] [timestampcolumn <String>]
|
[sortheaders <StringList>] [timestampcolumn <String>] [transpose [<Bopolean>]]
|
||||||
[todrive <ToDriveAttribute>*] |
|
[todrive <ToDriveAttribute>*] |
|
||||||
redirect stdout <FileName> [multiprocess] [append] |
|
redirect stdout <FileName> [multiprocess] [append] |
|
||||||
redirect stdout null [multiprocess] |
|
redirect stdout null [multiprocess] |
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
|
7.05.16
|
||||||
|
|
||||||
|
Added option `transpose [<Boolean>]` to `redirect csv` that causes
|
||||||
|
GAM to transpose CSV output rows and columns. This will most useful
|
||||||
|
when a `countsonly` option is used in a `print` or `report` command.
|
||||||
|
|
||||||
7.05.15
|
7.05.15
|
||||||
|
|
||||||
Updated `gam <UserTypeEntity> get drivefile` and `gam <UserTypeEntity> create drivefile`
|
Updated `gam <UserTypeEntity> get drivefile` and `gam <UserTypeEntity> create drivefile`
|
||||||
to allow downloading and uploading of Google App Scripts.
|
to allow downloading and uploading of Google Apps Scripts.
|
||||||
```
|
```
|
||||||
$ gam user user1@domain.com get drivefile 1ZY-YkS3E0OKipALra_XzfIh9cvxoILSbb8TRdHBFCpyB_mXI_J8FmjHv format json
|
$ gam user user1@domain.com get drivefile 1ZY-YkS3E0OKipALra_XzfIh9cvxoILSbb8TRdHBFCpyB_mXI_J8FmjHv format json
|
||||||
User: user1@domain.com, Download 1 Drive File
|
User: user1@domain.com, Download 1 Drive File
|
||||||
|
|||||||
@ -25,7 +25,7 @@ https://github.com/taers232c/GAMADV-XTD3/wiki
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__author__ = 'Ross Scroggs <ross.scroggs@gmail.com>'
|
__author__ = 'Ross Scroggs <ross.scroggs@gmail.com>'
|
||||||
__version__ = '7.05.15'
|
__version__ = '7.05.16'
|
||||||
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
||||||
|
|
||||||
#pylint: disable=wrong-import-position
|
#pylint: disable=wrong-import-position
|
||||||
@ -4113,8 +4113,8 @@ def SetGlobalVariables():
|
|||||||
if checkArgumentPresent(Cmd.MULTIPROCESSEXIT_CMD):
|
if checkArgumentPresent(Cmd.MULTIPROCESSEXIT_CMD):
|
||||||
_setMultiprocessExit()
|
_setMultiprocessExit()
|
||||||
# redirect csv <FileName> [multiprocess] [append] [noheader] [charset <CharSet>]
|
# redirect csv <FileName> [multiprocess] [append] [noheader] [charset <CharSet>]
|
||||||
# [columndelimiter <Character>] [noescapechar <Boolean>] [quotechar <Character>]]
|
# [columndelimiter <Character>] [noescapechar [<Boolean>]] [quotechar <Character>]]
|
||||||
# [sortheaders <StringList>] [timestampcolumn <String>]
|
# [sortheaders <StringList>] [timestampcolumn <String>] [transpose [<Boolean>]]
|
||||||
# [todrive <ToDriveAttribute>*]
|
# [todrive <ToDriveAttribute>*]
|
||||||
# redirect stdout <FileName> [multiprocess] [append]
|
# redirect stdout <FileName> [multiprocess] [append]
|
||||||
# redirect stdout null
|
# redirect stdout null
|
||||||
@ -4139,6 +4139,8 @@ def SetGlobalVariables():
|
|||||||
GM.Globals[GM.CSV_OUTPUT_SORT_HEADERS] = GC.Values[GC.CSV_OUTPUT_SORT_HEADERS] = getString(Cmd.OB_STRING_LIST, minLen=0).replace(',', ' ').split()
|
GM.Globals[GM.CSV_OUTPUT_SORT_HEADERS] = GC.Values[GC.CSV_OUTPUT_SORT_HEADERS] = getString(Cmd.OB_STRING_LIST, minLen=0).replace(',', ' ').split()
|
||||||
if checkArgumentPresent('timestampcolumn'):
|
if checkArgumentPresent('timestampcolumn'):
|
||||||
GM.Globals[GM.CSV_OUTPUT_TIMESTAMP_COLUMN] = GC.Values[GC.CSV_OUTPUT_TIMESTAMP_COLUMN] = getString(Cmd.OB_STRING, minLen=0)
|
GM.Globals[GM.CSV_OUTPUT_TIMESTAMP_COLUMN] = GC.Values[GC.CSV_OUTPUT_TIMESTAMP_COLUMN] = getString(Cmd.OB_STRING, minLen=0)
|
||||||
|
if checkArgumentPresent('transpose'):
|
||||||
|
GM.Globals[GM.CSV_OUTPUT_TRANSPOSE] = getBoolean()
|
||||||
_setCSVFile(filename, mode, encoding, writeHeader, multi)
|
_setCSVFile(filename, mode, encoding, writeHeader, multi)
|
||||||
GM.Globals[GM.CSVFILE][GM.REDIRECT_QUEUE_CSVPF] = CSVPrintFile()
|
GM.Globals[GM.CSVFILE][GM.REDIRECT_QUEUE_CSVPF] = CSVPrintFile()
|
||||||
if checkArgumentPresent('todrive'):
|
if checkArgumentPresent('todrive'):
|
||||||
@ -7794,6 +7796,7 @@ class CSVPrintFile():
|
|||||||
def __init__(self, titles=None, sortTitles=None, indexedTitles=None):
|
def __init__(self, titles=None, sortTitles=None, indexedTitles=None):
|
||||||
self.rows = []
|
self.rows = []
|
||||||
self.rowCount = 0
|
self.rowCount = 0
|
||||||
|
self.outputTranspose = GM.Globals[GM.CSV_OUTPUT_TRANSPOSE]
|
||||||
self.todrive = GM.Globals[GM.CSV_TODRIVE]
|
self.todrive = GM.Globals[GM.CSV_TODRIVE]
|
||||||
self.titlesSet = set()
|
self.titlesSet = set()
|
||||||
self.titlesList = []
|
self.titlesList = []
|
||||||
@ -8993,6 +8996,22 @@ class CSVPrintFile():
|
|||||||
self.JSONtitlesList = self.orderHeaders(self.JSONtitlesList)
|
self.JSONtitlesList = self.orderHeaders(self.JSONtitlesList)
|
||||||
titlesList = self.JSONtitlesList
|
titlesList = self.JSONtitlesList
|
||||||
normalizeSortHeaders()
|
normalizeSortHeaders()
|
||||||
|
if self.outputTranspose:
|
||||||
|
newRows = []
|
||||||
|
pivotKey = titlesList[0]
|
||||||
|
newTitlesList = [pivotKey]
|
||||||
|
newTitlesSet = set(newTitlesList)
|
||||||
|
for title in titlesList[1:]:
|
||||||
|
newRow = {pivotKey: title}
|
||||||
|
for row in self.rows:
|
||||||
|
pivotValue = row[pivotKey]
|
||||||
|
if pivotValue not in newTitlesSet:
|
||||||
|
newTitlesSet.add(pivotValue)
|
||||||
|
newTitlesList.append(pivotValue)
|
||||||
|
newRow[pivotValue] = row.get(title)
|
||||||
|
newRows.append(newRow)
|
||||||
|
titlesList = newTitlesList
|
||||||
|
self.rows = newRows
|
||||||
if (not self.todrive) or self.todrive['localcopy']:
|
if (not self.todrive) or self.todrive['localcopy']:
|
||||||
if GM.Globals[GM.CSVFILE][GM.REDIRECT_NAME] == '-':
|
if GM.Globals[GM.CSVFILE][GM.REDIRECT_NAME] == '-':
|
||||||
if GM.Globals[GM.STDOUT][GM.REDIRECT_MULTI_FD]:
|
if GM.Globals[GM.STDOUT][GM.REDIRECT_MULTI_FD]:
|
||||||
|
|||||||
@ -85,6 +85,8 @@ CSV_OUTPUT_ROW_FILTER_MODE = 'corm'
|
|||||||
CSV_OUTPUT_ROW_LIMIT = 'corl'
|
CSV_OUTPUT_ROW_LIMIT = 'corl'
|
||||||
# Add timestamp column to CSV output file
|
# Add timestamp column to CSV output file
|
||||||
CSV_OUTPUT_TIMESTAMP_COLUMN = 'cotc'
|
CSV_OUTPUT_TIMESTAMP_COLUMN = 'cotc'
|
||||||
|
# Transpose output rows/columns
|
||||||
|
CSV_OUTPUT_TRANSPOSE = 'cotr'
|
||||||
# Output sort headers
|
# Output sort headers
|
||||||
CSV_OUTPUT_SORT_HEADERS = 'cosh'
|
CSV_OUTPUT_SORT_HEADERS = 'cosh'
|
||||||
# CSV todrive options
|
# CSV todrive options
|
||||||
@ -250,6 +252,7 @@ Globals = {
|
|||||||
CSV_OUTPUT_ROW_LIMIT: 0,
|
CSV_OUTPUT_ROW_LIMIT: 0,
|
||||||
CSV_OUTPUT_SORT_HEADERS: [],
|
CSV_OUTPUT_SORT_HEADERS: [],
|
||||||
CSV_OUTPUT_TIMESTAMP_COLUMN: None,
|
CSV_OUTPUT_TIMESTAMP_COLUMN: None,
|
||||||
|
CSV_OUTPUT_TRANSPOSE: False,
|
||||||
CSV_TODRIVE: {},
|
CSV_TODRIVE: {},
|
||||||
CURRENT_API_SERVICES: {},
|
CURRENT_API_SERVICES: {},
|
||||||
CURRENT_CLIENT_API: None,
|
CURRENT_CLIENT_API: None,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user