Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
So I like datestrings in ISO format ie 2021-12-25 - it means you can just apply a simple sort and dates are in the right order.
But sometimes it is nice to see months as English rather trying to remember if October is 8th or ninth or tenth month. (maybe its just me).
So 2021-Dec-25 is nice to read but I lose that sort quality - this date would now appear before Thanksgiving on 2021-Nov-25.
So I was wondering if there was a human language that can do both - is there a language where January comes before February in that language's alphabet. For example French fails here (Janvier > Fevrier).
Well, let's query the cultures: for each culture we get months' names and check if they are sorted (we compare original names with the sorted names).
C# code:
var result = CultureInfo
.GetCultures(CultureTypes.AllCultures)
.Where(ci => ci.DateTimeFormat
.MonthNames
.Where(month => !string.IsNullOrEmpty(month))
.Where(month => !Regex.IsMatch(month, "^M[0-9]+$"))
.Any())
.Where(ci => ci.DateTimeFormat
.MonthNames
.Where(month => !string.IsNullOrEmpty(month))
.SequenceEqual(ci
.DateTimeFormat
.MonthNames
.Where(month => !string.IsNullOrEmpty(month))
.OrderBy(month => month)))
.OrderBy(ci => ci.Name)
.Select(ci => $"{ci.Name} ({ci.EnglishName})");
Console.Write(string.Join(Environment.NewLine, result));
Outcome:
Empty
So, there are no such (lucky?) cultures on the Earth (at least known to .Net 5)
You can try AbbreviatedMonthNames, MonthGenitiveNames, but alas: the output will be empty as well.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I am new to ruby and seeking help.
We got the csv files having the column with data shown below. Using the csv parser and fetch the column data for each in a variable.
And we want to change column data from csv file to line shown below and write to a file:
FROM
---
- - status
- New
- Delivered
TO
status from New to Delivered
Thanks #igian for help
---
- - status
- New
- Delivered
- - Milestone
- Sprint1
- Sprint
I was struggling for this. I tried to use y.second but it fails, please correct what I am doing wrong.
Looks like a YAML file, see https://ruby-doc.org/stdlib-2.6.2/libdoc/yaml/rdoc/YAML.html
Load the file then handle the array:
require 'yaml'
y = YAML.load_file( 'the_file.yaml' )
y #=> [["status", "New", "Delivered"]]
words = y.first
p "#{words[0]} from #{words[1]} to #{words[2]}"
#=> "status from New to Delivered"
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have a json file such as below, i need to split this flowfile into numbers of flowfile as per each line
Input flowfile:
{a:122, b: 12, c: dev}
{b: 19, c: dev}
{a:111, b: 12, c: roman,d: 2.3}
Output Flowfile will have 3 files with each row.
Splitjson is just just spliting the first line, please suggest
Do you have downstream processors that expect one JSON per flow file? Otherwise you may be able to skip the Split entirely and just use the Record processors (ConvertRecord, PutDatabaseRecord, e.g.). The JsonTreeReader (in later versions of NiFi) accept the one-JSON-per-line format (even though that's not valid JSON per se). If you do need one JSON object per flowfile, Bryan's suggestion of SplitText with a Line Count of 1 is spot-on.
SplitText with line count of 1
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have list of strings. I am trying to append those string values to a text file.
Here is my code:
java_location = "#{second}#{first}"
The output of java_location is:
1.6.0_43/opt/oracle/agent12c/core/12.1.0.4.0/jdk/bin/java
1.6.0_43/opt/oracle/agent12c/core/12.1.0.4.0/jdk/jre/bin/java
1.5.0/opt/itm/v6.2.2/JRE/lx8266/bin/java
1.6.0_35/u01/app/oracle/product/Middleware/Oracle_BI1/jdk/jre/bin/java
I want this output writing into a text file.
How can i do that?
File.write('file.txt', java_location)
You want to open the file in append mode ('a') rather than readwrite ('w+') which truncates the existing file to zero length before writing
http://alvinalexander.com/blog/post/ruby/example-how-append-text-to-file-ruby
if first && second
java_location = "#{second}#{first}"
a << java_location
File.open("/home/weblogic/javafoundmodified.txt", 'a') do |file|
a.each {
|item|
file.puts item
}
end
end
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
So I've been implementing a few different sorting methods (quick, merge, and insertion) and came across seemed a tad bit impractical and was wondering if someone could explain the thought process behind the behavior.
The list im trying to sort is the following:
[20401, 11087, 2, 62176, 70095, 20947, 20098, 90914, 53475, 51251, 20065]
The feedback is:
["11087", "2", "20065", "20098", "20401", "20947", "51251", "53475", "62176", "70095", "90914"]
If I change the 2 over to 00002 then I get a properly sorted list
["00002", "11087", "20065", "20098", "20401", "20947", "51251", "53475", "62176", "70095", "90914"]
Thanks ahead of time!
The respective two outputs that you are demostrating in the OP can be obtained as follows:
a = [20401, 11087, 2, 62176, 70095, 20947, 20098, 90914, 53475, 51251, 20065]
a.sort.map &"%05d".method( :% )
#=> ["00002", "11087", "20065", "20098", "20401", "20947", "51251", "53475", "62176", "70095", "90914"]
a.map( &:to_s ).sort
#=> ["11087", "2", "20065", "20098", "20401", "20947", "51251", "53475", "62176", "70095", "90914"]
Now what was the question, again?