예제 #1
0
    def spreadSheet(self, l, z, v, tank):
        """ Write the output data file.
        @param l Percentages of filling level.
        @param z Level z coordinates.
        @param v Volume of fluid.
        @param tank Active tank instance.
        """
        # Create the spreadsheet
        obj = Spreadsheet.makeSpreadsheet()
        s = obj.Proxy
        obj.Label = 'Capacity curve'

        # Print the header
        s.a1 = "Percentage of filling level"
        s.b1 = "Level [m]"
        s.c1 = "Volume [m^3]"

        # Print the data
        for i in range(len(l)):
            s.__setattr__("a{}".format(i + 2), l[i])
            s.__setattr__("b{}".format(i + 2), z[i])
            s.__setattr__("c{}".format(i + 2), v[i])

        # Open the spreadsheet
        FreeCADGui.ActiveDocument.setEdit(obj.Name, 0)
예제 #2
0
    def spreadSheet(self, l, z, v, tank):
        """ Write the output data file.
        @param l Percentages of filling level.
        @param z Level z coordinates.
        @param v Volume of fluid.
        @param tank Active tank instance.
        """
        # Create the spreadsheet
        obj = Spreadsheet.makeSpreadsheet()
        s = obj.Proxy
        obj.Label = 'Capacity curve'

        # Print the header
        s.a1 = "Percentage of filling level"
        s.b1 = "Level [m]"
        s.c1 = "Volume [m^3]"

        # Print the data
        for i in range(len(l)):
            s.__setattr__("a{}".format(i + 2), l[i])
            s.__setattr__("b{}".format(i + 2), z[i])
            s.__setattr__("c{}".format(i + 2), v[i])

        # Open the spreadsheet
        FreeCADGui.ActiveDocument.setEdit(obj.Name, 0)
예제 #3
0
def main(args):
    url = args.pop(0)
    print "url={}".format(url)
    sheet = Spreadsheet.Spreadsheet(url, 0, 0)
    sheet.rows = [row for row in sheet.rows if row.Description == "All industry total"]
    print sheet.get_csv()
    return 0
예제 #4
0
def main(url):
    if not url:
        return -1
    sheet = Spreadsheet.Spreadsheet(url, 1, 2)
    text = sheet.get_csv()
    print text
    return 0
 def connect_spreadsheet(self):
     self.db.out("Приосоединяемся к Гугл")
     self.ss = Spreadsheet.Spreadsheet(self.CREDENTIALS_FILE)
     self.ss.set_spreadsheet_byid(self.TABLE_ID)
     del self.TABLE_ID
     del self.CREDENTIALS_FILE
     # доделать с исключениеями
     return True
예제 #6
0
def main(*args):
    if not args:
        args = [URL]

    for url in args:
        print Spreadsheet.Spreadsheet(url, 1, 1).get_csv()

    return 0
예제 #7
0
def get_seds_for_state(state):
    rows = Spreadsheet.Loader(URL_COMPLETE_SEDS).get_rows()
    SEDS = namedtuple("SEDS", rows[0])
    entries = []
    for row in rows[1:]:
        entry = SEDS(*row)
        if entry.StateCode == state:
            entries.append(entry)
    return entries
예제 #8
0
    def spreadSheet(self, ship, trim):
        """ Write data file.
        @param ship Selected ship instance
        @param trim Trim in degrees.
        @return True if error happens.
        """
        # Create the spreadsheet
        obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",
                                               "Spreadsheet")
        s = Spreadsheet.Spreadsheet(obj)
        if FreeCAD.GuiUp:
            Spreadsheet.ViewProviderSpreadsheet(obj.ViewObject)
        FreeCAD.ActiveDocument.recompute()
        obj.Label = 'Hydrostatics'

        # Print the header
        s.a1 = "displacement [ton]"
        s.b1 = "draft [m]"
        s.c1 = "wetted surface [m^2]"
        s.d1 = "1cm triming ship moment [ton*m]"
        s.e1 = "Floating area [m^2]"
        s.f1 = "KBl [m]"
        s.g1 = "KBt [m]"
        s.h1 = "BMt [m]"
        s.i1 = "Cb"
        s.j1 = "Cf"
        s.k1 = "Cm"

        for i in range(len(self.points)):
            point = self.points[i]
            s.__setattr__("a{}".format(i + 2), point.disp)
            s.__setattr__("b{}".format(i + 2), point.draft)
            s.__setattr__("c{}".format(i + 2), point.wet)
            s.__setattr__("d{}".format(i + 2), point.mom)
            s.__setattr__("e{}".format(i + 2), point.farea)
            s.__setattr__("f{}".format(i + 2), point.xcb)
            s.__setattr__("g{}".format(i + 2), point.KBt)
            s.__setattr__("h{}".format(i + 2), point.BMt)
            s.__setattr__("i{}".format(i + 2), point.Cb)
            s.__setattr__("j{}".format(i + 2), point.Cf)
            s.__setattr__("k{}".format(i + 2), point.Cm)

        # Open the spreadsheet
        FreeCADGui.ActiveDocument.setEdit(obj.Name, 0)
예제 #9
0
    def spreadSheet(self, x, y, ship):
        """ Write the output data file.
        @param x X coordinates.
        @param y Transversal areas.
        @param ship Active ship instance.
        """
        # Create the spreadsheet
        obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython", "Spreadsheet")
        s = Spreadsheet.Spreadsheet(obj)
        if FreeCAD.GuiUp:
            Spreadsheet.ViewProviderSpreadsheet(obj.ViewObject)
        FreeCAD.ActiveDocument.recompute()
        obj.Label = 'Areas curve'

        # Print the header
        s.a1 = "x [m]"
        s.b1 = "area [m^2]"
        s.c1 = "FP x"
        s.d1 = "FP y"
        s.e1 = "AP x"
        s.f1 = "AP y"

        # Print the perpendiculars data
        Lpp = ship.Length.getValueAs('m').Value
        FPx = 0.5 * Lpp
        APx = -0.5 * Lpp
        maxArea = max(y)
        s.c2 = FPx
        s.d2 = 0.0
        s.c3 = FPx
        s.d3 = maxArea
        s.e2 = APx
        s.f2 = 0.0
        s.e3 = APx
        s.f3 = maxArea

        # Print the data
        for i in range(len(x)):
            s.__setattr__("a{}".format(i + 2), x[i])
            s.__setattr__("b{}".format(i + 2), y[i])

        # Open the spreadsheet
        FreeCADGui.ActiveDocument.setEdit(obj.Name,0)
예제 #10
0
def main(args):
    url = EIA_URL if not args else args[0]
    sheet = Spreadsheet.Spreadsheet(url, 0, 3)

    sheet.rows = [
        row for row in sheet.rows if row.Customs_District == "Honolulu, HI"
    ]

    print sheet.get_csv()

    return 0
예제 #11
0
    def save_as_xls(self,filen):
        """Output the workbook contents to an Excel-format file

        Arguments:
          filen: name of the file to write the workbook to.

        """
        xls = Spreadsheet.Workbook()
        for name in self.worksheet:
            worksheet = self.worksheet[name]
            ws = xls.addSheet(worksheet.title)
            ws.addText(worksheet.render_as_text(include_styles=True))
        xls.save(filen)
예제 #12
0
def main(args):
    if not args:
        return -1

    files = list(sorted(args))

    header = Spreadsheet.Spreadsheet(files[-1], 0).header
    fields = header._fields

    print DELIM.join(Spreadsheet.row_to_strs(fields))

    for fname in files:
        sys.stderr.write(
            "Extracting Petroleum Import entries for Hawaii from {}...\n".
            format(fname))
        blank = header(*[str()] * len(fields))
        sheet = Spreadsheet.Spreadsheet(fname, 0)
        for row in sheet.rows:
            tmp = blank._replace(**row._asdict())
            if tmp.PORT_STATE in ["HAWAII", "HI"]:
                print DELIM.join(Spreadsheet.row_to_strs(tmp))

    return 0
예제 #13
0
def main():
    when = sys.argv[1]
    spreadsheet = Spreadsheet.Spreadsheet(when)
    tweet_text = get_tweet_text(spreadsheet)
    image_url = get_tweet_image_url(spreadsheet)

    CONFIGS = load_config()
    api = twitter.Api(consumer_key=CONFIGS["CONSUMER_KEY"],
                      consumer_secret=CONFIGS["CONSUMER_SECRET"],
                      access_token_key=CONFIGS["ACCESS_TOKEN_KEY"],
                      access_token_secret=CONFIGS["ACCESS_TOKEN_SECRET"])

    post_tweet(api, tweet_text, image_url)
    print(tweet_text, image_url)
    print(get_my_one_tweet(api).text)
예제 #14
0
    def cast_values(value):
        if type(value) not in [type(0.0), type(0)]:
            value = Spreadsheet.safe_str(value).strip()

            try:
                fval = float(value)
                value = fval
            except:
                pass

        if type(value) == type(0.0):
            if isclose(value, int(value)):
                value = int(value)

        return value
예제 #15
0
def getMentionedStocks():
    # Setup for all urls
    urlList = Spreadsheet.getURLs()
    symbols = ReadSymbols.getSymbols()

    # mentions will track the number of times a stock has been mentioned
    mentions = {}
    for sym in symbols:
        mentions[sym] = 0

    urlNum = 0
    for url in urlList:
        urlNum += 1
        print("URL " + str(urlNum) + "/" + str(len(urlList)))
        foundOnSite = []

        try:
            text = getTextFromURL(url)
        except:
            print("FAILED URL : " + url)
            continue

        # print(url) # DEBUG CODE
        for line in text:
            if(line.find('(') != -1):
                for sym in symbols:
                    if(sym in foundOnSite):
                        continue

                    if(line.find("("+sym+")") != -1 or line.find(":"+sym+")") != -1):
                        # print(sym + " : " + line) # DEBUG CODE
                        mentions[sym] += 1
                        foundOnSite.append(sym)

    # get the stocks that were mentioned more than once and sort them accordingly
    highMentions = []
    for key in mentions.keys():
        if(mentions[key] > 0):
            # print(key + " : " + str(mentions[key])) # DEBUG CODE
            highMentions.append((key, mentions[key]))
    
    highMentions = sorted(highMentions, key= lambda x: x[1], reverse=True)

    print()
    print("NUMBER OF STOCKS FOUND : " + str(len(highMentions)))
    return highMentions
예제 #16
0
파일: PlotAux.py 프로젝트: OLGGL/Model
    def spreadSheet(self, ship, trim):
        """ Write data file.
        @param ship Selected ship instance
        @param trim Trim in degrees.
        @return True if error happens.
        """
        # Create the spreadsheet
        obj = Spreadsheet.makeSpreadsheet()
        s = obj.Proxy
        obj.Label = 'Hydrostatics'

        # Print the header
        s.a1 = "displacement [ton]"
        s.b1 = "draft [m]"
        s.c1 = "wetted surface [m^2]"
        s.d1 = "1cm triming ship moment [ton*m]"
        s.e1 = "Floating area [m^2]"
        s.f1 = "KBl [m]"
        s.g1 = "KBt [m]"
        s.h1 = "BMt [m]"
        s.i1 = "Cb"
        s.j1 = "Cf"
        s.k1 = "Cm"

        for i in range(len(self.points)):
            point = self.points[i]
            s.__setattr__("a{}".format(i + 2), point.disp)
            s.__setattr__("b{}".format(i + 2), point.draft)
            s.__setattr__("c{}".format(i + 2), point.wet)
            s.__setattr__("d{}".format(i + 2), point.mom)
            s.__setattr__("e{}".format(i + 2), point.farea)
            s.__setattr__("f{}".format(i + 2), point.xcb)
            s.__setattr__("g{}".format(i + 2), point.KBt)
            s.__setattr__("h{}".format(i + 2), point.BMt)
            s.__setattr__("i{}".format(i + 2), point.Cb)
            s.__setattr__("j{}".format(i + 2), point.Cf)
            s.__setattr__("k{}".format(i + 2), point.Cm)

        # Open the spreadsheet
        FreeCADGui.ActiveDocument.setEdit(obj.Name,0)
예제 #17
0
    def spreadSheet(self, x, y, ship):
        """ Write the output data file.
        @param x X coordinates.
        @param y Transversal areas.
        @param ship Active ship instance.
        """
        # Create the spreadsheet
        obj = Spreadsheet.makeSpreadsheet()
        s = obj.Proxy
        obj.Label = 'Areas curve'

        # Print the header
        s.a1 = "x [m]"
        s.b1 = "area [m^2]"
        s.c1 = "FP x"
        s.d1 = "FP y"
        s.e1 = "AP x"
        s.f1 = "AP y"

        # Print the perpendiculars data
        Lpp = ship.Length.getValueAs('m').Value
        FPx = 0.5 * Lpp
        APx = -0.5 * Lpp
        maxArea = max(y)
        s.c2 = FPx
        s.d2 = 0.0
        s.c3 = FPx
        s.d3 = maxArea
        s.e2 = APx
        s.f2 = 0.0
        s.e3 = APx
        s.f3 = maxArea

        # Print the data
        for i in range(len(x)):
            s.__setattr__("a{}".format(i + 2), x[i])
            s.__setattr__("b{}".format(i + 2), y[i])

        # Open the spreadsheet
        FreeCADGui.ActiveDocument.setEdit(obj.Name,0)
def get_fields_records_from_csv(url):
    csv = Spreadsheet.Spreadsheet(url, None, 0, True)

    fstr = "col_{}"

    col_row = False
    fields = list(csv.header._fields)
    if col_row:
        fields = ["row"] + fields

    fields = [{"id": fstr.format(field), "type": "text"} for field in fields]

    records = [row._asdict() for row in csv.rows]

    records = [
        collections.OrderedDict([("col_row",
                                  "{:03d}".format(i + 1))] if col_row else [] +
                                [(fstr.format(f), v)
                                 for f, v in row.iteritems()])
        for i, row in enumerate(records)
    ]

    return fields, records
예제 #19
0
    """

    def handle_ready(self):
        print("Logged in as")
        print(self.bot.user.name)
        print(self.bot.user.id)
        print("------------")

        msg = "Jarod's WTS_Bot reporting for duty!"
        channels = self.bot.get_all_channels()
        for channel in channels:
            if str(channel) == self.channel_name:
                return (channel, msg)


spreadsheet = Spreadsheet(SPREADSHEET_ID)
wrapper = Bot(countries, "human", TOKEN, spreadsheet)


@wrapper.bot.event
async def on_message(message):
    result = wrapper.handle_message(message)
    if (result != None):
        channel = result[0]
        messages = result[1]
        option = result[2]
        for message in messages:
            if option == 0:
                await wrapper.bot.send_message(channel, message)
            elif option == 1:
                await wrapper.bot.send_file(channel, message)
예제 #20
0
def make_hawaii_seds_csv_text():
    hi_rows = make_state_table("HI")
    csv_text = Spreadsheet.rows_to_csv(hi_rows)
    return csv_text
def get_hawaii_co2_emissions_csv_text():
    co2 = get_co2_url()
    data = Spreadsheet.Spreadsheet(co2, None, 2)
    data = filter_co2_by_states(data, ["Hawaii"])
    text = data.get_csv()
    return text
예제 #22
0
chr\tChromosome location of binding region
start\tStart coordinate of binding region
end\tEnd coordinate of binding region
summit-100\tSummit - 100bp
summit+100\tSummit + 100bp
summit-1\tSummit of binding region - 1
summit\tSummit of binding region
length\tLength of binding region
summit\tPeak of summit region from the start position of the binding region
tags\tNumber of non-degenerate and position corrected reads in the binding region
-10*LOG10(pvalue)\tTransformed Pvalue -10*log10(Pvalue) for the binding region (e.g. if Pvalue=1e-10, then this value should be 100)
fold_enrichment\tFold enrichment for this region against random Poisson distribution with local lambda
FDR(%)\tFalse discovery rate (FDR) as a percentage
"""
    # Create a new spreadsheet
    wb = Spreadsheet.Workbook()

    # Create the sheets
    #
    # data = the actual data from MACS
    ws_data = wb.addSheet(
        os.path.basename(macs_in)[:min(30, len(os.path.basename(macs_in)))])
    #
    # note = the header data
    ws_notes = wb.addSheet("notes")
    ws_notes.addText("<style font=bold>MACS RUN NOTES:</style>")
    ws_notes.addTabData(header)
    ws_notes.addText(
        "\n<style font=bold>ADDITIONAL NOTES:</style>\nBy default regions are sorted by Pvalue and fold enrichment (in descending order)"
    )
    #
    def __init__(self, line_argument=None):
        self.CREDENTIALS_FILE = "creds.json"
        cfg = configparser.ConfigParser()
        cfg.read('settings.cfg')
        # spreadsheet секция
        self.TABLE_ID = cfg["spreadsheet"]["gogletableid"]
        self.cell_color = cfg["spreadsheet"]["cell_color"]
        self.cell_calendar = cfg["spreadsheet"]["cell_calendar"]
        self.cell_user = cfg["spreadsheet"]["cell_user"]
        self.cell_log = cfg["spreadsheet"]["cell_log"]
        self.sheets = {
            "work_sheet": (cfg["spreadsheet"]["work_sheet"],
                           cfg["spreadsheet"]["work_sheet_id"])
        }

        self.sheets["project_sheet"] = (cfg["spreadsheet"]["project_sheet"],
                                        cfg["spreadsheet"]["project_sheet_id"])
        self.column_project = cfg["spreadsheet"]["column_project"]
        self.table_project = cfg["spreadsheet"]["table_project"]
        self.table_params = cfg["spreadsheet"]["table_params"]
        self.table_plan = cfg["spreadsheet"]["table_plan"]
        self.start_work_table = cfg["spreadsheet"]["start_work_table"]
        self.column_id = cfg["spreadsheet"]["column_id"]
        self.column_log = cfg["spreadsheet"]["column_log"]
        self.column_link = cfg["spreadsheet"]["column_link"]
        columns_stage = cfg["spreadsheet"]["columns_stage"]
        self.columns_stage = columns_stage.split(",")
        self.cell_progress = cfg["spreadsheet"]["cell_progress"]
        self.column_comand = cfg["spreadsheet"]["column_comand"]
        self.color_bc_finish = Spreadsheet.htmlColorToJSON("#cfe2f3")
        self.color_font_finish = Spreadsheet.htmlColorToJSON("#000000")
        self.color_bc = Spreadsheet.htmlColorToJSON("#6aa84f")
        self.color_font = Spreadsheet.htmlColorToJSON("#ffffff")
        custom_value_name = cfg["spreadsheet"]["custom_value_name"]
        self.custom_value_name = custom_value_name.split(",")
        custom_value_key = cfg["spreadsheet"]["custom_value_key"]
        self.custom_value_key = custom_value_key.split(",")
        custom_value_adr = cfg["spreadsheet"]["custom_value_adr"]
        self.custom_value_adr = custom_value_adr.split(",")
        # wrike секция
        self.TOKEN = cfg["wrike"]["wriketoken"]
        self.prototip_link = cfg["wrike"]["prototip_link"]
        self.folder_link = cfg["wrike"]["folder_link"]
        # log секция
        self.OUT = cfg["log"]["out"]
        self.NAME = cfg["log"]["name"]
        self.PASS = cfg["log"]["pass"]
        self.HOST = cfg["log"]["host"]
        self.BASE = cfg["log"]["base"]
        # параметры для аргументов запуска руководитель и номер строки
        self.rp_filter = None
        self.row_filter = None
        self.HOLYDAY = None
        self.COLOR_FINISH = None
        self.wr = None
        self.ss = None
        self.db = None
        self.template_id = None
        self.parent_id = None
        self.users_name = None
        self.users_id = None
        self.users_name = None
        self.users_id = None

        self.user_token = None
        self.rp_filter = None
        self.row_filter = None

        # обрабатываем список аргументов
        # 0 - сам скрипт
        # 1-й токен пользователя или admin для админа - логи только в терминал
        # 1   help - помощь по параметрам запускаа
        # 2-й -rp
        # 3-й читаем если есть -rp -  менеджер проекта по которому фильтр
        # 4-й -n
        # 5-й читаем еслить есть -n номер строки котору обрабатывать
        if not line_argument:
            line_argument = ["", "admin"]
        if len(line_argument) == 1:
            self.user_token = None
        else:
            self.user_token = line_argument[1]
        if len(line_argument) >= 4:
            key = line_argument[2]
            if key == "-rp":
                self.rp_filter = line_argument[3]
            elif key == "-n":
                self.row_filter = int(line_argument[3])
        if len(line_argument) == 6:
            key = line_argument[4]
            if key == "-rp":
                self.rp_filter = line_argument[5]
            elif key == "-n":
                self.row_filter = int(line_argument[5])
예제 #24
0
def get_msn_codes_and_descriptions_data():
    ss = Spreadsheet.Loader(*URL_SEDS_DESC_SHEET)
    return ss.get_rows()
예제 #25
0
def fetch_DBEDT_databook_population_rows():
    url = "http://files.hawaii.gov/dbedt/economic/databook/Data_Book_time_series/sec01update.xls"
    population_sheet_name = "01.04"
    ss = Spreadsheet.Loader(url, population_sheet_name)
    return ss.get_rows()
예제 #26
0
def get_fixed_population_csv():
    pop_rows = fetch_DBEDT_databook_population_rows()
    fixed_pop_rows = fixup_population(pop_rows)
    csv_text = Spreadsheet.rows_to_csv(fixed_pop_rows)
    return csv_text