4,331 questions
-3
votes
2
answers
154
views
String not recognized as a valid DateTime [closed]
I'm receiving this date and time in US format from an upstream server I have no control over and can't change: 12/16/2024 11:30:23 AM
I am trying to convert it to UK format using PowerShell:
[DateTime]...
0
votes
1
answer
121
views
C++17 compiler warns "unknown conversion type character ‘.’ in format" for "%.12e" format string
I am updating some legacy code that is a mixture of C and C++. I am using a modern compiler (C++17) and building with Makefile. I get a warning for this line of code:
sscanf(data_buffer, "%d,%....
0
votes
0
answers
45
views
What's the proper way to group each 3 characters with comma?
This Excel-like layout is implemented using RecyclerView.
For each EditTexts, the inputType is text because the requirement is to accepts these 2 formats:
Numeric input (separated by comma each 3 ...
0
votes
0
answers
37
views
Streaming text from openai in next.js
"Streaming Text Formatting" – Formatting text that arrives in chunks from a stream.
"Real-time Text Structuring"
I am creating a web app using next.js and openai
When I use openai ...
1
vote
1
answer
126
views
Format number to a string such that spaces are inserted rather than 0s
When you convert some number to a string and pass in a format such as "00", it will insert 0's if the number doesn't have digits filling that spot. Example:
1.ToString("00") -> &...
1
vote
1
answer
145
views
C++23 formatting mdspan as matrix
I'm trying to specify a formatter to print mdspan of rank 2 as a matrix, quite useful. I would like at least for element formatting to work, e.g. std::println("{::.2e}", matrix) would print ...
0
votes
2
answers
66
views
WPF TextBox typing issue with StringFormat
Is there a way to "bypass" the dot and "override" the decimals when typing a value in a TextBox in WPF formatted with a 2 decimals via StringFormat='{}{0:F2} ?
When I type "1....
0
votes
1
answer
268
views
How to format numbers with precision in strings when precision is only a runtime known value?
I have the following Zig snippet:
var buffer: [20]u8 = undefined;
const precise_string = std.fmt.bufPrint(&buffer, "{d:.d}", .{ max, precision }) catch unreachable;
std.debug.print("...
0
votes
0
answers
65
views
Printing a numpy variable with and without format gives different values
While working with numpy, I observed something strange. When I print a variable using print() and I format the print usingprint(f'{<variable>:.9f}) gives different values.
For example,
or
I am ...
1
vote
0
answers
76
views
Python formatting float to n signficaint digits
I would like to convert a set of floats to strings with 3 significant digits, e.g.
10.00 --> 10.0
10.10 --> 10.1
101.10 --> 101
Using "{:.3g}".format(x) results in 10, 10.1, 101 ...
4
votes
1
answer
151
views
Validate if a string matches a format string
In Ruby, you can parse a string into a DateTime based on a given format string, for example:
3.2.4 :001 > DateTime.strptime(Time.now.to_s, '%Y-%m-%d %H:%M')
Sat, 17 Aug 2024 13:31:00 +0000
3.2.4 :...
1
vote
1
answer
74
views
Is it possible to conditionally override levelname in formatting of Python logger?
I am currently working on some Python code that will be executed by a larger C# web project. The C# code uses NLog to create log files. I have got my Python logger logging to the same file. Also, I ...
0
votes
1
answer
77
views
How would I format a string value from a custom list into money format?
I know this is likely a duplicate question and for that I am sorry. I have been looking for a way to format a custom string, that is pulling values from SQL database. I have read many S.O. on ...
0
votes
1
answer
859
views
How to correctly and simply display multiline string literal in Jupyter Notebook?
I am looking for a solution that is the most convenient for casual, exploratory notebook use.
I have several functions that output strings with multiple lines. When this appears in the output cell of ...
2
votes
3
answers
2k
views
How can I make certain text bold in Python string formatting?
I have a snippet where I generate a string that includes an original number (original_number) and its corresponding Roman numeral (roman_number). I want to format this string so that the original ...
0
votes
1
answer
129
views
Formatting specific rows in Pandas Dataframe with string formatting and heatmap
Here I have a code for a function that creates a formatted table.It currently works but I want to optimise it considering "Setting an item of incompatible dtype is deprecated and will raise an ...
0
votes
1
answer
619
views
MAUI XAML Label with Different Font size
I need a label to show a number in the range of thousands. I'm not using thousand separator as per requested, but I want the user to be able to focus on the thousands. For example if I were to show &...
0
votes
3
answers
702
views
Strings are printed like integer with scientific notation in python
a=str(141528231211101319151414.0)
print(a)
# 1.4152823121110133e+23
This string was printed with scientific notation. I do not understand why.
I am using mpmath to deal with arithmetic operations ...
0
votes
1
answer
151
views
How to format float to omit zeros at the end of the fraction
I'd like to format a float so that it has at most 3 fractional digits, but if the last fractional digit(s) are 0 then omit them.
input : expected output
1.1234 : 1.123
1.120 : 1.12
1.100 : 1.1
1.0 : 1
...
3
votes
2
answers
260
views
Powershell is not recognising a date that has been formatted in datetime format
I am searching Splunk using powershell via API and get a list of data that contain dates (not in DateTime format).
The API call is performed by a Function that works fine and it works for the inital ...
-3
votes
1
answer
160
views
How do I return True if a string in a cell is contained anywhere in a column?
I am working in google sheets. Excel also works.
I have column called "funds." This column has names of venture funds, such as Accel, A16z, and Sequoia. One fund in each row.
I have another ...
0
votes
3
answers
752
views
Use str.format to format numbers with a minimum of 1 decimal place without rounding and without adding additional trailing zeroes
Context
I am receiving numbers as strings in Python 3 and want to transmit them as strings in order to preserve accuracy so that the upstream server can convert the numbers-as-strings to decimal....
0
votes
1
answer
124
views
Tuple unpacking to formatted string in Python
I have been working though Fluent Python 2nd Edition by Luciano Ramalho.
On page 5 he writes that he has attempted to adopt the f string syntax throughout the book, although there are times when str....
0
votes
2
answers
567
views
C# String Format for Scientific Notation if greater than a certain number of digits
I have a series of numbers that can be either large integers, or very small decimals. I would like numbers with more than four digits to be displayed in scientific notation.
At first, I considered a ...
1
vote
1
answer
127
views
Is a formatted string still a string? Is it still printable, or it is just a bunch of rules?
I am looking at other code on a Java practice. Here is his code:
import java.util.Arrays;
import java.util.stream.Collectors;
public class StripComments {
public static String stripComments(...