formatting

Pad number with variable length zeroes using REGEX

北城以北 提交于 2020-06-01 02:23:45
问题 I have a situation where client inputs a number, and I need to validate that number by padding a certain number of zeroes in front of it. The max length of the field that I validate is 9 digits, so if client enters '123', I need to pad it with 6 zeros in front of it and validate. Sounds easy enough, right? Well, here is the kicker, I have no code-control over any part of the process. The only things available to me are 2 'properties' - a regex pattern and a regex replace that already existing

Google Sheets =MONTH works but MONTH in QUERY does not

筅森魡賤 提交于 2020-05-28 11:54:05
问题 Google Sheets: I checked my column of dates is in DATE format not Automatic . When I use MONTH in a cell I get the correct month back from that column. When I do a QUERY such as =query('Main'!A1:M20,"select MONTH(M)",1) I get #VALUE! with the comment: Unable to parse the Function QUERY for parameter 2: Can't perform the function MONTH on a column that is not a DATE or a DATETIME column Why does QUERY not see the column as being in DATE format but =MONTH does? 回答1: months in a query are

Highlight entire row when cell is active

一世执手 提交于 2020-05-14 14:41:34
问题 How to design a sheet script that would result in an active row being highlighted? I would like to have an entire row change color of font or background when one cell in that row is active. I don't want the trigger to be any specific value in the cell, just clicking on a cell should trigger the highlight for the whole row that cell belongs to. 回答1: Sorry, this can't be done with conditional formatting or script by just selecting a cell. You can, however, highlight an entire row of the active

Python Pandas Apply Formatting to Each Column in Dataframe Using a Dict Mapping

你说的曾经没有我的故事 提交于 2020-05-10 21:04:24
问题 Problem Setup import pandas as pd df = pd.DataFrame(data={'Currency': {0: 111.23, 1: 321.23}, 'Int': {0: 23, 1: 3}, 'Rate': {0: 0.03030, 1: 0.09840}} ) Produces the following DataFrame Currency Int Rate 0 111.23 23 0.0303 1 321.23 3 0.0984 I want to apply very specific formatting to each column in the dataframe using a dict like the following: format_mapping={'Currency': '${:,.2f}', 'Int': '{:,.0f}', 'Rate': '{:.2f}%'} I know I can use applymap for multiple columns or apply on a single column

Selected Text Formatting in WPF RichTexBox

a 夏天 提交于 2020-04-18 01:06:11
问题 I am trying to implement programmatically selected (using regex) text formatting in a WPF RichTextBox. The use case is simply a WPF RichTextBox in which the user types text. However, to improve or accelerate readability i want to incorporate some automatic formatting as the text is typed. The following code from How to select text from the RichTextBox and then color it? is exactly what i am trying to do. However, as far as i can tell this code is for a WinForms RichTextBox: public void

I want to load a YAML file, possibly edit the data, and then dump it again. How can I preserve formatting?

放肆的年华 提交于 2020-04-17 00:20:22
问题 This question tries to collect information spread over questions about different languages and YAML implementations in a mostly language-agnostic manner. Suppose I have a YAML file like this: first: - foo: {a: "b"} - "bar": [1, 2, 3] second: | # some comment some long block scalar value I want to load this file into an native data structure, possibly change or add some values, and dump it again. However, when I dump it, the original formatting is not preserved: The scalars are formatted

I want to load a YAML file, possibly edit the data, and then dump it again. How can I preserve formatting?

为君一笑 提交于 2020-04-17 00:18:57
问题 This question tries to collect information spread over questions about different languages and YAML implementations in a mostly language-agnostic manner. Suppose I have a YAML file like this: first: - foo: {a: "b"} - "bar": [1, 2, 3] second: | # some comment some long block scalar value I want to load this file into an native data structure, possibly change or add some values, and dump it again. However, when I dump it, the original formatting is not preserved: The scalars are formatted

Django Logger with User info

送分小仙女□ 提交于 2020-04-16 06:20:12
问题 I'm just curious. Is it possible to put User info within the formatters info in LOGGING config in setting.py ? Right now I just put that info in the message to log but maybe there's a way to set it in formatters argument. This is my LOGGING configuration right now: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, 'simple': { 'format': '[%(asctime)s] %(levelname)s [%

Spring custom formatter to field annotation does not work

房东的猫 提交于 2020-04-16 03:58:21
问题 I'm trying to apply formatter-annotation to the field "phone" in next model-class: public class User { @ContactNumberFormate private String phone; } Interface for annotation: @Target({ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface ContactNumberFormate { } Formatter: @Component public class PhoneFormatter implements Formatter<String> { @Override public String parse(String phoneNum, Locale locale) throws ParseException { phoneNum = phoneNum.trim();

Google Chart arrayToDataTable formatted value not working

别说谁变了你拦得住时间么 提交于 2020-04-14 07:41:27
问题 I am followinf the google Chart documentation for arrayToDataTable and the example states that I can use formatted values, like that: var data = google.visualization.arrayToDataTable([ ['Employee Name', 'Salary'], ['Mike', {v:22500, f:'18,500'}], ... where f:'18,500 is the formatted value to show. My code looks identical: var data = google.visualization.arrayToDataTable([ ['Category', 'Amount'], ['Food', {v:5595.819984, f:'5.595,82'}], ['Home', {v:1890.530002, f:'1.890,53'}], ['Mail', {v:8