I have a text file contains settingsname , settingsvalue and UserName with tab delimited. In the text file I have more than 100 default settings. If any user changes any default setting, I will not overwrite the default setting with new setting. Instead of, I added a new record by mentioning the username. When retrieving data, Initially I am loading default settings one map container (string, string). (settingsname is key, settingsvalue is Value) Then I loading the specific user settings in a another map. And Overriding the default map with user map using the below code.
for(it=usrMap.begin();it!=usrMap.end();it++)
{
defMap[it->first]=it->second;
}
The text file contains Data in a Specific order. Its not sorted alphabetically. While printing the default map values , I want the data in the order what I specified in a Text file. I can't keep settings name in a ordered way for some reason. How can I do this using map ?
a std::map cannot be made stable; it will 'sort' the elements using the hashfunction. if the order is important, you can keep ordered keys in a vector (for example) and access the map in the order suggested by the vector.
Related
I have a scenario where the user will upload a file with some data and a header in that file. i need to process the file and make sure that the field names in the header are correct and have no whitespaces and no special characters.
eg. User dropped file in storage account contains the following header
i need to change it to this
How can i do this ADF v2 ?
Data Factory won't really do this as is, but if this is part of a larger ETL process, you can rename the columns in a Data Flow using Select.
Source:
Add a Select node and go to the "Select settings" tab. If you know the schema, you can just fix the columns manually here:
You can also use a Rule-based mapping to remove spaces from all the column names. To do this, remove all the existing mappings and add the following:
"true()" in this context means apply to all columns, and '$$' refers to the column name. The "Inspect" tab will show the updated column names:
I have this setup like in illustration attached, hope it clear enough. I load all xls files in loop from given folder.
While implementing new Derived Column box to record FileName from my loop I got truncation error. My variable initially was set to CCS.xls (Len=7, shortest name ).
I tried to increase Length in Derived Column Editor but failed to do this, as it's not active, I can't not type anything there, then I track that that original Length came from Variables value. In Variable windows I have DataType = String and no any option to set length.
So for now I made dummy empty file with looong CCS____1.xls name to avoid this problem and it works OK. But want to learn other good way to avoid this problem, looks like in this setup for data connection I need to use file with longest name (?)
You can change the Length property to 50 or larger manually in Advanced Editor.
Right-Click on the Derived column->Show Advanced Editor->Input and Output Properties->Derived Column Output->Output Columns->the new Column->Data Type Properties->Length
I am using Taleo Connect Client to export data from Taleo. I encountered two questions:
How can I add blank columns to an output CSV file?
For example, try to add ColumnBlank1 between Column_FirstName and Column_LastName.
Column_FirstName|ColumnBlank1|Column_LastName
John||Lee
Adam||Jackson
How can I set default value like "N" for one field?
DBaluke Huang's answer was correct, but he left out some details. Adding the full solution for others who might need this too.
To export a blank or fixed string value in a column using TCC (Taleo Connect client) do the following:
Open your Export
Click the projections tab
Click the add button
Click Projection Function
Choose the Replace Function
Click ok
In the First Parameter Section: In the Value box, add any string field
from your list on the entity tab. The Data Type should be Field.
In the Second Parameter Section, In the Value box, add the same field
from Parameter 1 value box. The Data Type should be Field.
In the Third Parameter section, In the value box, enter no value for
blank or enter the fixed string you want in all records.
Then change the data type to string in this section.
For those unfamiliar with the replace function you are looking for the string Parameter1.Value in Parameter2.value and then replacing all instances where the string is found with parameter3.value
You can export a blank field with <quer:string/>.
<quer:projection alias="Blank" xmlns:quer="http://www.taleo.com/ws/integration/query">
<quer:string/>
</quer:projection>
Steps
Open your export in Taleo Connect Client.
Open the General tab and set the Export mode to "CSV-report".
Open the Projections tab.
Click Add.
Select Add a complex projection and click OK.
Under Complex projection, enter the following:
<quer:projection alias="Blank" xmlns:quer="http://www.taleo.com/ws/integration/query">
<quer:string/>
</quer:projection>
Save your changes.
Example:
<quer:query productCode="RC1704" model="http://www.taleo.com/ws/tee800/2009/01" projectedClass="Candidate" locale="en" mode="CSV" csvheader="true" csvdelimiter="|" largegraph="true" preventDuplicates="false" xmlns:quer="http://www.taleo.com/ws/integration/query">
<quer:subQueries/>
<quer:projections>
<quer:projection>
<quer:field path="FirstName"/>
</quer:projection>
<quer:projection alias="Blank">
<quer:string/>
</quer:projection>
<quer:projection>
<quer:field path="LastName"/>
</quer:projection>
</quer:projections>
<quer:projectionFilterings/>
<quer:filterings/>
<quer:sortings/>
<quer:sortingFilterings/>
<quer:groupings/>
<quer:joinings/>
</quer:query>
Results:
FirstName|Blank|LastName
John||Lee
Adam||Jackson
Jane||Doe
Notes:
If you get a SAX parsing error when running the export, make sure your Export mode is set to "CSV-report". (Appears as mode="CSV" in source)
When adding a complex projection in TCC, you must include xmlns:quer="http://www.taleo.com/ws/integration/query", or else TCC will call your source "invalid". However, it is not required when editing your export's source directly outside of TCC.
I resolved the issue by:
Add a function projection in Projections. Set your Alias. Set First parameter value as whatever field that available. Set the second parameter's value as same as the first parameter. Change Third parameter's value as "blank" and set Data type as String.
Same step as the first question, and set Change Third parameter's value as "N".
I want to split a panel in two and open the current file in the new pane? I used to believe that alt+shift+2 would do the job. But it isn't working for me. How can I do it?
You can use multiple key bindings for that. Based on the file containing the default key-bindings:
alt+shift+2: set two column layout and focus on second group (currently empty second column).
ctrl+1: focus on first group.
ctrl+shift+2: move current file to second group (right column).
If you want to do it with a unique key-binding you can see this or this question and others that explain how to use a unique key-binding containing multiple commands.
Note: the given key-bindings work under Linux. Key-bidings on Windows or OS X may be different.
I'm having a strange issue.
I created a model observer for my user model. The model observer is being run at 'saving'. when I dump the object at the very end of the user model to be displayed ( this is just before it saves.. according to laravel docs ) it displays all the attributes set correctly for the object, I've even seen an error that showed the correct attributes as set and being inserted into my database table. However, after the save has been completed and I query the database, two of the fields are not saved into the table.
There is no code written by myself sitting between the point where I dumped the attributes to check that they had been set and the save operation to the database. so I have no idea what could be causing this to happen. All the names are set correctly, and like I said, the attributes show as being inserted into the database, they just never end up being saved, I receive no error messages and only two out of ten attributes aren't being saved.
In my searches I have found many posts detailing that the $fillable property should be set, or issues relating to a problem with variables being misnamed or unset, however because I already have the specific attributes not being saved specified in the $fillable array, on top of the fact that they print out exactly as expected pre save, I don't believe those issues are related to the problem I am experiencing.
to save I'm calling:
User::create(Input::all());
and then the observer that handles the data looks like this:
class UserObserver {
# a common key between the city and state tables, helps to identify correct city
$statefp = State::where('id',$user->state_id)->pluck('statefp');
# trailing zeros is a function that takes the first parameter and adds zeros to make sure
# that in this case for example, the dates will be two characters with a trailing zero,
# based on the number specified in the second parameter
$user->birth_date = $user->year.'-'.$user->trailingZeros( $user->month, 2 ).'-'.$user->trailingZeros( $user->day, 2 );
if(empty($user->city)){
$user->city_id = $user->defaultCity;
}
$user->city_id = City::where( 'statefp', $statefp )->where('name', ucfirst($user->city_id))->pluck('id');
# if the user input zip code is different then suggested zip code then find location data
# on the input zip code input by the user from the geocodes table
if( $user->zip !== $user->defaultZip ){
$latlon = Geocode::where('zip', $user->zip)->first();
$user->latitude = $latlon['latitude'];
$user->longitude = $latlon['longitude'];
}
unset($user->day);
unset($user->month);
unset($user->year);
unset($user->defaultZip);
unset($user->defaultCity);
}
that is the code for the two values that aren't being set, when I run
dd($user);
all the variables are set correctly, and show up in the mysql insert attempt screen with correct values, but they do not persist past that point.. it seems to me that possibly mysql is rejecting the values for the city_id and the birth_date. However, I cannot understand why, or whether it is a problem with Laravel or mysql.
since I was calling
User::create();
I figured I'd try to have my observer listen to:
creating();
I'm not sure why it only effected the date and city variables, but changing the function to listen at creating() instead of saving() seems to have solved my problem.