[{"data":1,"prerenderedAt":2090},["ShallowReactive",2],{"/blog/learn-python-with-pj-part-4-dictionaries-and-files":3,"navigation-en-us":1338,"banner-en-us":1776,"footer-en-us":1784,"blog-post-authors-en-us-PJ Metz":2031,"blog-related-posts-en-us-learn-python-with-pj-part-4-dictionaries-and-files":2047,"blog-share-wrapper-en-us":2070,"next-steps-en-us":2080},{"id":4,"title":5,"authors":6,"body":8,"category":1318,"date":1319,"description":1320,"extension":1321,"externalUrl":1322,"faq":1322,"featured":1323,"heroImage":1324,"hidePromo":1323,"meta":1325,"navigation":586,"path":1326,"seo":1327,"slug":1331,"stem":1332,"tags":1333,"template":1336,"updatedDate":1322,"__hash__":1337},"blogPosts/en-us/blog/learn-python-with-pj-part-4-dictionaries-and-files.md","Learn Python with Pj! Part 4 - Dictionaries and Files",[7],"PJ Metz",{"type":9,"value":10,"toc":1310},"minimark",[11,15,44,47,50,55,63,169,180,360,379,390,623,626,752,768,772,775,780,791,844,859,903,907,932,971,975,986,1055,1058,1061,1269,1298,1306],[12,13,14],"p",{},"This is the fourth installment in the Learn Python with Pj! series. Make sure to read:",[16,17,18,26,32,38],"ul",{},[19,20,21],"li",{},[22,23,25],"a",{"href":24},"/blog/learn-python-with-pj-part-1/","Part 1 - Getting started",[19,27,28],{},[22,29,31],{"href":30},"/blog/learn-python-with-pj-part-2/","Part 2 - Lists and loops",[19,33,34],{},[22,35,37],{"href":36},"/blog/learn-python-with-pj-part-3/","Part 3 - Functions and strings",[19,39,40],{},[22,41,43],{"href":42},"/blog/learn-python-with-pj-part-5-building-something-with-the-twitter-api/","Part 5 - Build a hashtag tracker with the Twitter API",[12,45,46],{},"I’ve learned a lot with Python so far, but when I learned dictionaries (sometimes shortened to dicts), I was really excited about what could be done. A dictionary in Python is a series of keys and values stored inside a single object. This is kind of like a super array; one that allows you to connect keys and values together in a single easily accessible source. Creating dictionaries from arrays can actually be very simple, too.",[12,48,49],{},"In this blog, I'll dig into how to create dictionaries and how to read and write files in the code.",[51,52,54],"h2",{"id":53},"dictionaries","Dictionaries",[12,56,57,58,62],{},"Dictionaries in Python are indicated by using curly braces, or as I like to call them, mustaches. ",[59,60,61],"code",{},"{ }"," indicates that the list you’re looking at isn’t a list at all, but a dictionary.",[64,65,70],"pre",{"className":66,"code":67,"language":68,"meta":69,"style":69},"language-python shiki shiki-themes github-light","shows_and _characters = {\n    \"Bojack Horseman\": \"Todd\",\n    \"My Hero Academia\": \"Midoriya\"\n    \"Ozark\": \"Ruth\"\n    \"Arrested Development\": \"Tobias\",\n    \"Derry Girls\": \"Sister Michael\",\n    \"Tuca & Bertie\": \"Bertie\"\n    }\n\n","python","",[59,71,72,88,104,115,126,139,152,163],{"__ignoreMap":69},[73,74,77,81,85],"span",{"class":75,"line":76},"line",1,[73,78,80],{"class":79},"sgsFI","shows_and _characters ",[73,82,84],{"class":83},"sD7c4","=",[73,86,87],{"class":79}," {\n",[73,89,91,95,98,101],{"class":75,"line":90},2,[73,92,94],{"class":93},"sYBdl","    \"Bojack Horseman\"",[73,96,97],{"class":79},": ",[73,99,100],{"class":93},"\"Todd\"",[73,102,103],{"class":79},",\n",[73,105,107,110,112],{"class":75,"line":106},3,[73,108,109],{"class":93},"    \"My Hero Academia\"",[73,111,97],{"class":79},[73,113,114],{"class":93},"\"Midoriya\"\n",[73,116,118,121,123],{"class":75,"line":117},4,[73,119,120],{"class":93},"    \"Ozark\"",[73,122,97],{"class":79},[73,124,125],{"class":93},"\"Ruth\"\n",[73,127,129,132,134,137],{"class":75,"line":128},5,[73,130,131],{"class":93},"    \"Arrested Development\"",[73,133,97],{"class":79},[73,135,136],{"class":93},"\"Tobias\"",[73,138,103],{"class":79},[73,140,142,145,147,150],{"class":75,"line":141},6,[73,143,144],{"class":93},"    \"Derry Girls\"",[73,146,97],{"class":79},[73,148,149],{"class":93},"\"Sister Michael\"",[73,151,103],{"class":79},[73,153,155,158,160],{"class":75,"line":154},7,[73,156,157],{"class":93},"    \"Tuca & Bertie\"",[73,159,97],{"class":79},[73,161,162],{"class":93},"\"Bertie\"\n",[73,164,166],{"class":75,"line":165},8,[73,167,168],{"class":79},"    }\n",[12,170,171,172,175,176,179],{},"This is a dictionary of my favorite TV shows and my favorite characters in that show. In this example, the key is on the left and the value is on the right. To access dictionaries, you use a similar call like you would for a list, except instead of an element number, you would put the key. ",[59,173,174],{},"print(shows_and_characters[“Ozark”])"," would print ",[59,177,178],{},"Ruth"," to the console. Additionally, both the key and value in this example are strings, but that’s not a requirement. Keys can be any immutable type, like strings, ints, floats, and tuples. Values don’t have this same restriction, therefore values can be a nested dictionary or a list, in addition to the types mentioned for keys. For instance, the following dictionary is a valid dictionary.",[64,181,183],{"className":66,"code":182,"language":68,"meta":69,"style":69},"shows_with_lists = {\n    \"Bojack Horseman\": [\"Todd\", \"Princess Carolyn\", \"Judah\", \"Diane\"],\n    \"My Hero Academia\": [\"Midoriya\", \"Shoto\", \"All Might\", \"Bakugo\", \"Kirishima\"],\n    \"Ozark\": [\"Ruth\", \"Jonah\", \"Wyatt\"],\n    \"Arrested Development\": [\"Tobias\", \"Gob\", \"Anne\", \"Maeby\"],\n    \"Derry Girls\": [\"Sister Michael\", \"Orla\", \"Erin\", \"Claire\", \"James\"],\n    \"Tuca & Bertie\": [\"Bertie\", \"Speckle\", \"Tuca\", \"Dakota\"]\n    }\n\n",[59,184,185,194,222,253,274,299,329,356],{"__ignoreMap":69},[73,186,187,190,192],{"class":75,"line":76},[73,188,189],{"class":79},"shows_with_lists ",[73,191,84],{"class":83},[73,193,87],{"class":79},[73,195,196,198,201,203,206,209,211,214,216,219],{"class":75,"line":90},[73,197,94],{"class":93},[73,199,200],{"class":79},": [",[73,202,100],{"class":93},[73,204,205],{"class":79},", ",[73,207,208],{"class":93},"\"Princess Carolyn\"",[73,210,205],{"class":79},[73,212,213],{"class":93},"\"Judah\"",[73,215,205],{"class":79},[73,217,218],{"class":93},"\"Diane\"",[73,220,221],{"class":79},"],\n",[73,223,224,226,228,231,233,236,238,241,243,246,248,251],{"class":75,"line":106},[73,225,109],{"class":93},[73,227,200],{"class":79},[73,229,230],{"class":93},"\"Midoriya\"",[73,232,205],{"class":79},[73,234,235],{"class":93},"\"Shoto\"",[73,237,205],{"class":79},[73,239,240],{"class":93},"\"All Might\"",[73,242,205],{"class":79},[73,244,245],{"class":93},"\"Bakugo\"",[73,247,205],{"class":79},[73,249,250],{"class":93},"\"Kirishima\"",[73,252,221],{"class":79},[73,254,255,257,259,262,264,267,269,272],{"class":75,"line":117},[73,256,120],{"class":93},[73,258,200],{"class":79},[73,260,261],{"class":93},"\"Ruth\"",[73,263,205],{"class":79},[73,265,266],{"class":93},"\"Jonah\"",[73,268,205],{"class":79},[73,270,271],{"class":93},"\"Wyatt\"",[73,273,221],{"class":79},[73,275,276,278,280,282,284,287,289,292,294,297],{"class":75,"line":128},[73,277,131],{"class":93},[73,279,200],{"class":79},[73,281,136],{"class":93},[73,283,205],{"class":79},[73,285,286],{"class":93},"\"Gob\"",[73,288,205],{"class":79},[73,290,291],{"class":93},"\"Anne\"",[73,293,205],{"class":79},[73,295,296],{"class":93},"\"Maeby\"",[73,298,221],{"class":79},[73,300,301,303,305,307,309,312,314,317,319,322,324,327],{"class":75,"line":141},[73,302,144],{"class":93},[73,304,200],{"class":79},[73,306,149],{"class":93},[73,308,205],{"class":79},[73,310,311],{"class":93},"\"Orla\"",[73,313,205],{"class":79},[73,315,316],{"class":93},"\"Erin\"",[73,318,205],{"class":79},[73,320,321],{"class":93},"\"Claire\"",[73,323,205],{"class":79},[73,325,326],{"class":93},"\"James\"",[73,328,221],{"class":79},[73,330,331,333,335,338,340,343,345,348,350,353],{"class":75,"line":154},[73,332,157],{"class":93},[73,334,200],{"class":79},[73,336,337],{"class":93},"\"Bertie\"",[73,339,205],{"class":79},[73,341,342],{"class":93},"\"Speckle\"",[73,344,205],{"class":79},[73,346,347],{"class":93},"\"Tuca\"",[73,349,205],{"class":79},[73,351,352],{"class":93},"\"Dakota\"",[73,354,355],{"class":79},"]\n",[73,357,358],{"class":75,"line":165},[73,359,168],{"class":79},[12,361,362,363,366,367,370,371,374,375,378],{},"In this example, each value is a list. So if we tried to print the value for the key ",[59,364,365],{},"”Derry Girls”",", we would see ",[59,368,369],{},"[“Sister Michael”, “Orla”, “Erin”, “Claire”, “James”]"," printed to the console. However, if we wanted the last element in the value list, we’d write ",[59,372,373],{},"shows_with_lists[“Derry Girls”] [-1]",". This would print the last element in the list, which in this case is ",[59,376,377],{},"James",".",[12,380,381,382,385,386,389],{},"Dictionaries can be written manually, or, if you have two lists, you can combine the ",[59,383,384],{},"dict()"," and ",[59,387,388],{},"zip()"," methods to make the lists into a dictionary.",[64,391,393],{"className":66,"code":392,"language":68,"meta":69,"style":69},"list_of_shows = [\"Bojack Horseman\",\n                 \"My Hero Academia\",\n                 \"Ozark\",\n                 \"Arrested Development\",\n                 \"Derry Girls\",\n                 \"Tuca & Bertie\"]\nlist_of_characters = [[\"Todd\", \"Princess Carolyn\", \"Judah\", \"Diane\"],\n                      [\"Midoriya\", \"Shoto\", \"All Might\", \"Bakugo\", \"Kirishima\"],\n                      [\"Ruth\", \"Jonah\", \"Wyatt\"],\n                      [\"Tobias\", \"Gob\", \"Anne\", \"Maeby\"],\n                      [\"Sister Michael\", \"Orla\", \"Erin\", \"Claire\", \"James\"],\n                      [\"Bertie\", \"Speckle\", \"Tuca\", \"Dakota\"]]\n\ncombined_shows_characters = dict(zip(list_of_shows, list_of_characters))\n\nprint(combined_shows_characters)\n",[59,394,395,410,417,424,431,438,445,471,496,513,534,559,581,588,609,614],{"__ignoreMap":69},[73,396,397,400,402,405,408],{"class":75,"line":76},[73,398,399],{"class":79},"list_of_shows ",[73,401,84],{"class":83},[73,403,404],{"class":79}," [",[73,406,407],{"class":93},"\"Bojack Horseman\"",[73,409,103],{"class":79},[73,411,412,415],{"class":75,"line":90},[73,413,414],{"class":93},"                 \"My Hero Academia\"",[73,416,103],{"class":79},[73,418,419,422],{"class":75,"line":106},[73,420,421],{"class":93},"                 \"Ozark\"",[73,423,103],{"class":79},[73,425,426,429],{"class":75,"line":117},[73,427,428],{"class":93},"                 \"Arrested Development\"",[73,430,103],{"class":79},[73,432,433,436],{"class":75,"line":128},[73,434,435],{"class":93},"                 \"Derry Girls\"",[73,437,103],{"class":79},[73,439,440,443],{"class":75,"line":141},[73,441,442],{"class":93},"                 \"Tuca & Bertie\"",[73,444,355],{"class":79},[73,446,447,450,452,455,457,459,461,463,465,467,469],{"class":75,"line":154},[73,448,449],{"class":79},"list_of_characters ",[73,451,84],{"class":83},[73,453,454],{"class":79}," [[",[73,456,100],{"class":93},[73,458,205],{"class":79},[73,460,208],{"class":93},[73,462,205],{"class":79},[73,464,213],{"class":93},[73,466,205],{"class":79},[73,468,218],{"class":93},[73,470,221],{"class":79},[73,472,473,476,478,480,482,484,486,488,490,492,494],{"class":75,"line":165},[73,474,475],{"class":79},"                      [",[73,477,230],{"class":93},[73,479,205],{"class":79},[73,481,235],{"class":93},[73,483,205],{"class":79},[73,485,240],{"class":93},[73,487,205],{"class":79},[73,489,245],{"class":93},[73,491,205],{"class":79},[73,493,250],{"class":93},[73,495,221],{"class":79},[73,497,499,501,503,505,507,509,511],{"class":75,"line":498},9,[73,500,475],{"class":79},[73,502,261],{"class":93},[73,504,205],{"class":79},[73,506,266],{"class":93},[73,508,205],{"class":79},[73,510,271],{"class":93},[73,512,221],{"class":79},[73,514,516,518,520,522,524,526,528,530,532],{"class":75,"line":515},10,[73,517,475],{"class":79},[73,519,136],{"class":93},[73,521,205],{"class":79},[73,523,286],{"class":93},[73,525,205],{"class":79},[73,527,291],{"class":93},[73,529,205],{"class":79},[73,531,296],{"class":93},[73,533,221],{"class":79},[73,535,537,539,541,543,545,547,549,551,553,555,557],{"class":75,"line":536},11,[73,538,475],{"class":79},[73,540,149],{"class":93},[73,542,205],{"class":79},[73,544,311],{"class":93},[73,546,205],{"class":79},[73,548,316],{"class":93},[73,550,205],{"class":79},[73,552,321],{"class":93},[73,554,205],{"class":79},[73,556,326],{"class":93},[73,558,221],{"class":79},[73,560,562,564,566,568,570,572,574,576,578],{"class":75,"line":561},12,[73,563,475],{"class":79},[73,565,337],{"class":93},[73,567,205],{"class":79},[73,569,342],{"class":93},[73,571,205],{"class":79},[73,573,347],{"class":93},[73,575,205],{"class":79},[73,577,352],{"class":93},[73,579,580],{"class":79},"]]\n",[73,582,584],{"class":75,"line":583},13,[73,585,587],{"emptyLinePlaceholder":586},true,"\n",[73,589,591,594,596,600,603,606],{"class":75,"line":590},14,[73,592,593],{"class":79},"combined_shows_characters ",[73,595,84],{"class":83},[73,597,599],{"class":598},"sYu0t"," dict",[73,601,602],{"class":79},"(",[73,604,605],{"class":598},"zip",[73,607,608],{"class":79},"(list_of_shows, list_of_characters))\n",[73,610,612],{"class":75,"line":611},15,[73,613,587],{"emptyLinePlaceholder":586},[73,615,617,620],{"class":75,"line":616},16,[73,618,619],{"class":598},"print",[73,621,622],{"class":79},"(combined_shows_characters)\n",[12,624,625],{},"This is one way to create a dictionary. Another is called Dictionary Comprehension. This one is a little more work, but can be used in a variety of different ways, including using a bit of logic on a single list to generate a dictionary using that original list. Here’s how with two examples: one based on the above lists, and one with a single list and some logic.",[64,627,629],{"className":66,"code":628,"language":68,"meta":69,"style":69},"import math\n\n#This is doing the same work as the above example, but using Dict Comprehension instead. \ncomprehension_shows_characters = { shows:characters for shows, characters in zip(list_of_shows, list_of_characters)  }\n\nhip_to_be_square = [4, 9, 16, 25, 36, 49]\n\nno_longer_hip_to_be_square = { key:math.sqrt(key) for key in hip_to_be_square }\n\nprint(no_longer_hip_to_be_square)\n",[59,630,631,639,643,649,674,678,717,721,741,745],{"__ignoreMap":69},[73,632,633,636],{"class":75,"line":76},[73,634,635],{"class":83},"import",[73,637,638],{"class":79}," math\n",[73,640,641],{"class":75,"line":90},[73,642,587],{"emptyLinePlaceholder":586},[73,644,645],{"class":75,"line":106},[73,646,648],{"class":647},"sAwPA","#This is doing the same work as the above example, but using Dict Comprehension instead. \n",[73,650,651,654,656,659,662,665,668,671],{"class":75,"line":117},[73,652,653],{"class":79},"comprehension_shows_characters ",[73,655,84],{"class":83},[73,657,658],{"class":79}," { shows:characters ",[73,660,661],{"class":83},"for",[73,663,664],{"class":79}," shows, characters ",[73,666,667],{"class":83},"in",[73,669,670],{"class":598}," zip",[73,672,673],{"class":79},"(list_of_shows, list_of_characters)  }\n",[73,675,676],{"class":75,"line":128},[73,677,587],{"emptyLinePlaceholder":586},[73,679,680,683,685,687,690,692,695,697,700,702,705,707,710,712,715],{"class":75,"line":141},[73,681,682],{"class":79},"hip_to_be_square ",[73,684,84],{"class":83},[73,686,404],{"class":79},[73,688,689],{"class":598},"4",[73,691,205],{"class":79},[73,693,694],{"class":598},"9",[73,696,205],{"class":79},[73,698,699],{"class":598},"16",[73,701,205],{"class":79},[73,703,704],{"class":598},"25",[73,706,205],{"class":79},[73,708,709],{"class":598},"36",[73,711,205],{"class":79},[73,713,714],{"class":598},"49",[73,716,355],{"class":79},[73,718,719],{"class":75,"line":154},[73,720,587],{"emptyLinePlaceholder":586},[73,722,723,726,728,731,733,736,738],{"class":75,"line":165},[73,724,725],{"class":79},"no_longer_hip_to_be_square ",[73,727,84],{"class":83},[73,729,730],{"class":79}," { key:math.sqrt(key) ",[73,732,661],{"class":83},[73,734,735],{"class":79}," key ",[73,737,667],{"class":83},[73,739,740],{"class":79}," hip_to_be_square }\n",[73,742,743],{"class":75,"line":498},[73,744,587],{"emptyLinePlaceholder":586},[73,746,747,749],{"class":75,"line":515},[73,748,619],{"class":598},[73,750,751],{"class":79},"(no_longer_hip_to_be_square)\n",[12,753,754,755,758,759,762,763,378],{},"In the ",[59,756,757],{},"no_longer_hip_to_be_square"," dictionary, the key is found in the ",[59,760,761],{},"hip_to_be_square"," list. The value for each key is its own square root, brought in with the import math function. There are plenty more useful methods for dealing with dictionaries ",[22,764,767],{"href":765,"rel":766},"https://realpython.com/python-dicts/",[],"here",[51,769,771],{"id":770},"reading-and-writing-files","Reading and writing files",[12,773,774],{},"This one is a pretty cool part of Python: reading and writing other files right in the code. With Python, you’re able to take the contents of certain types of files and use it in your code, or even create a new file based on some input. This is useful for data handling and can be used with a  variety of file types. The two I’ll be covering here are .csv and .txt.",[776,777,779],"h3",{"id":778},"reading-from-a-file","Reading from a file",[12,781,782,783,786,787,790],{},"Imagine a .txt file named ",[59,784,785],{},"best-ever.txt"," containing the line ",[59,788,789],{},"My favorite tv show is Derry Girls",". We can use Python to take that line and turn it into a variable. Running the following code would print the contents of the .txt file to the terminal.",[64,792,794],{"className":66,"code":793,"language":68,"meta":69,"style":69},"with open(\"best-ever.txt\") as text_file:\n  text_data = text_file.read()\n\n#This will print the contents of the .txt file. \nprint(text_data)\n",[59,795,796,818,828,832,837],{"__ignoreMap":69},[73,797,798,801,804,806,809,812,815],{"class":75,"line":76},[73,799,800],{"class":83},"with",[73,802,803],{"class":598}," open",[73,805,602],{"class":79},[73,807,808],{"class":93},"\"best-ever.txt\"",[73,810,811],{"class":79},") ",[73,813,814],{"class":83},"as",[73,816,817],{"class":79}," text_file:\n",[73,819,820,823,825],{"class":75,"line":90},[73,821,822],{"class":79},"  text_data ",[73,824,84],{"class":83},[73,826,827],{"class":79}," text_file.read()\n",[73,829,830],{"class":75,"line":106},[73,831,587],{"emptyLinePlaceholder":586},[73,833,834],{"class":75,"line":117},[73,835,836],{"class":647},"#This will print the contents of the .txt file. \n",[73,838,839,841],{"class":75,"line":128},[73,840,619],{"class":598},[73,842,843],{"class":79},"(text_data)\n",[12,845,846,847,850,851,854,855,858],{},"By using ",[59,848,849],{},"with open(NAME OF FILE) as VARIABLE_NAME:",", we can examine the contents of files as a single string. If the document has multiple lines, you can even separate those by iterating over them by using a for loop and the ",[59,852,853],{},".readlines()"," method. Using an imaginary .txt document called ",[59,856,857],{},"buncha-lines"," we could use the following to print out each line individually.",[64,860,862],{"className":66,"code":861,"language":68,"meta":69,"style":69},"with open(\"buncha-lines.txt\") as lines_doc:\n  for line in lines_doc.readlines():\n    print(line)\n\n",[59,863,864,882,895],{"__ignoreMap":69},[73,865,866,868,870,872,875,877,879],{"class":75,"line":76},[73,867,800],{"class":83},[73,869,803],{"class":598},[73,871,602],{"class":79},[73,873,874],{"class":93},"\"buncha-lines.txt\"",[73,876,811],{"class":79},[73,878,814],{"class":83},[73,880,881],{"class":79}," lines_doc:\n",[73,883,884,887,890,892],{"class":75,"line":90},[73,885,886],{"class":83},"  for",[73,888,889],{"class":79}," line ",[73,891,667],{"class":83},[73,893,894],{"class":79}," lines_doc.readlines():\n",[73,896,897,900],{"class":75,"line":106},[73,898,899],{"class":598},"    print",[73,901,902],{"class":79},"(line)\n",[776,904,906],{"id":905},"writing-a-new-file","Writing a new file",[12,908,909,910,913,914,917,918,920,921,924,925,928,929,378],{},"Creating a new file is also easy with Python. The ",[59,911,912],{},"open()"," function can take an additional argument in order to create a new file. In fact, there’s a default argument that’s been being passed each time without us knowing! ",[59,915,916],{},"r"," is the default argument for ",[59,919,912],{}," and puts it in read mode. To turn on write mode, pass in a ",[59,922,923],{},"w"," as the second argument. The following code will write a brand-new file called ",[59,926,927],{},"best_tv_character.txt"," with the contents ",[59,930,931],{},"Peggy Olson from Mad Men",[64,933,935],{"className":66,"code":934,"language":68,"meta":69,"style":69},"with open(\"best_tv_character.txt\", \"w\") as best_character:\n  best_character.write(\"Peggy Olson from Mad Men\")\n\n",[59,936,937,960],{"__ignoreMap":69},[73,938,939,941,943,945,948,950,953,955,957],{"class":75,"line":76},[73,940,800],{"class":83},[73,942,803],{"class":598},[73,944,602],{"class":79},[73,946,947],{"class":93},"\"best_tv_character.txt\"",[73,949,205],{"class":79},[73,951,952],{"class":93},"\"w\"",[73,954,811],{"class":79},[73,956,814],{"class":83},[73,958,959],{"class":79}," best_character:\n",[73,961,962,965,968],{"class":75,"line":90},[73,963,964],{"class":79},"  best_character.write(",[73,966,967],{"class":93},"\"Peggy Olson from Mad Men\"",[73,969,970],{"class":79},")\n",[776,972,974],{"id":973},"working-with-csv-files","Working with .csv files",[12,976,977,978,981,982,985],{},"You can read a .csv file with Python by using ",[59,979,980],{},"import csv"," at the beginning of the file, and then using some of its built-in methods in the code. However, even though .csv files are plain text, treating a .csv file the same as you treat .txt files can lead to difficult to read outputs; after all, the point of a spreadsheet is to table information. Without that table, the output can be chaotic. A way around this is to use the ",[59,983,984],{},"dictreader()"," method. This method allows you to map the information in each row to a dictionary with field names you can create. The default field names are collected from the first row of the .csv if no field names are given. Imagine a .csv file with columns labeled, “Network”, “Show name”, “Seasons”. Maybe we just want to print the number of seasons from this .csv.",[64,987,989],{"className":66,"code":988,"language":68,"meta":69,"style":69},"import csv \n\nwith open(\"shows.csv\") as shows_csv:\n  shows_dict = csv.DictReader(shows_csv)\n  for row in shows_dict:\n    print(row[\"Seasons\"])\n\n",[59,990,991,998,1002,1020,1030,1042],{"__ignoreMap":69},[73,992,993,995],{"class":75,"line":76},[73,994,635],{"class":83},[73,996,997],{"class":79}," csv \n",[73,999,1000],{"class":75,"line":90},[73,1001,587],{"emptyLinePlaceholder":586},[73,1003,1004,1006,1008,1010,1013,1015,1017],{"class":75,"line":106},[73,1005,800],{"class":83},[73,1007,803],{"class":598},[73,1009,602],{"class":79},[73,1011,1012],{"class":93},"\"shows.csv\"",[73,1014,811],{"class":79},[73,1016,814],{"class":83},[73,1018,1019],{"class":79}," shows_csv:\n",[73,1021,1022,1025,1027],{"class":75,"line":117},[73,1023,1024],{"class":79},"  shows_dict ",[73,1026,84],{"class":83},[73,1028,1029],{"class":79}," csv.DictReader(shows_csv)\n",[73,1031,1032,1034,1037,1039],{"class":75,"line":128},[73,1033,886],{"class":83},[73,1035,1036],{"class":79}," row ",[73,1038,667],{"class":83},[73,1040,1041],{"class":79}," shows_dict:\n",[73,1043,1044,1046,1049,1052],{"class":75,"line":141},[73,1045,899],{"class":598},[73,1047,1048],{"class":79},"(row[",[73,1050,1051],{"class":93},"\"Seasons\"",[73,1053,1054],{"class":79},"])\n",[12,1056,1057],{},"This would print to the console, on a new line, the number of seasons for each row that exists in the .csv.",[12,1059,1060],{},"Just like with .txt files, you can also create .csv files with Python. It’s a bit more complicated since you need to define the headers, or column names, but it is still a quick process. This can be used to take lists and turn them into .csv files. Let’s check out the following example:",[64,1062,1064],{"className":66,"code":1063,"language":68,"meta":69,"style":69},"import csv\n\nworking_list = [{\"Network\": \"Netflix\", \"Show Name\":\"Bojack Horseman\", \"Seasons\":6}, {\"Network\":\"Channel 4\",\"Show Name\":\"Derry Girls\", \"Seasons\": 3}, {\"Network\":\"HBO Max\", \"Show Name\":\"Our Flag Means Death\", \"Seasons\": 1}]\n\n\nwith open(\"shows.csv\", \"w\") as shows_csv:\n    fields = [\"Network\", \"Show Name\", \"Seasons\"]\n    shows_w = csv.DictWriter(shows_csv, fieldnames = fields)\n\n    shows_w.writeheader()\n    for item in working_list:\n        shows_w.writerow(item)\n\n",[59,1065,1066,1073,1077,1173,1177,1181,1201,1222,1242,1246,1251,1264],{"__ignoreMap":69},[73,1067,1068,1070],{"class":75,"line":76},[73,1069,635],{"class":83},[73,1071,1072],{"class":79}," csv\n",[73,1074,1075],{"class":75,"line":90},[73,1076,587],{"emptyLinePlaceholder":586},[73,1078,1079,1082,1084,1087,1090,1092,1095,1097,1100,1103,1105,1107,1109,1111,1114,1117,1119,1121,1124,1127,1129,1131,1134,1136,1138,1140,1143,1145,1147,1149,1152,1154,1156,1158,1161,1163,1165,1167,1170],{"class":75,"line":106},[73,1080,1081],{"class":79},"working_list ",[73,1083,84],{"class":83},[73,1085,1086],{"class":79}," [{",[73,1088,1089],{"class":93},"\"Network\"",[73,1091,97],{"class":79},[73,1093,1094],{"class":93},"\"Netflix\"",[73,1096,205],{"class":79},[73,1098,1099],{"class":93},"\"Show Name\"",[73,1101,1102],{"class":79},":",[73,1104,407],{"class":93},[73,1106,205],{"class":79},[73,1108,1051],{"class":93},[73,1110,1102],{"class":79},[73,1112,1113],{"class":598},"6",[73,1115,1116],{"class":79},"}, {",[73,1118,1089],{"class":93},[73,1120,1102],{"class":79},[73,1122,1123],{"class":93},"\"Channel 4\"",[73,1125,1126],{"class":79},",",[73,1128,1099],{"class":93},[73,1130,1102],{"class":79},[73,1132,1133],{"class":93},"\"Derry Girls\"",[73,1135,205],{"class":79},[73,1137,1051],{"class":93},[73,1139,97],{"class":79},[73,1141,1142],{"class":598},"3",[73,1144,1116],{"class":79},[73,1146,1089],{"class":93},[73,1148,1102],{"class":79},[73,1150,1151],{"class":93},"\"HBO Max\"",[73,1153,205],{"class":79},[73,1155,1099],{"class":93},[73,1157,1102],{"class":79},[73,1159,1160],{"class":93},"\"Our Flag Means Death\"",[73,1162,205],{"class":79},[73,1164,1051],{"class":93},[73,1166,97],{"class":79},[73,1168,1169],{"class":598},"1",[73,1171,1172],{"class":79},"}]\n",[73,1174,1175],{"class":75,"line":117},[73,1176,587],{"emptyLinePlaceholder":586},[73,1178,1179],{"class":75,"line":128},[73,1180,587],{"emptyLinePlaceholder":586},[73,1182,1183,1185,1187,1189,1191,1193,1195,1197,1199],{"class":75,"line":141},[73,1184,800],{"class":83},[73,1186,803],{"class":598},[73,1188,602],{"class":79},[73,1190,1012],{"class":93},[73,1192,205],{"class":79},[73,1194,952],{"class":93},[73,1196,811],{"class":79},[73,1198,814],{"class":83},[73,1200,1019],{"class":79},[73,1202,1203,1206,1208,1210,1212,1214,1216,1218,1220],{"class":75,"line":154},[73,1204,1205],{"class":79},"    fields ",[73,1207,84],{"class":83},[73,1209,404],{"class":79},[73,1211,1089],{"class":93},[73,1213,205],{"class":79},[73,1215,1099],{"class":93},[73,1217,205],{"class":79},[73,1219,1051],{"class":93},[73,1221,355],{"class":79},[73,1223,1224,1227,1229,1232,1236,1239],{"class":75,"line":165},[73,1225,1226],{"class":79},"    shows_w ",[73,1228,84],{"class":83},[73,1230,1231],{"class":79}," csv.DictWriter(shows_csv, ",[73,1233,1235],{"class":1234},"sqxcx","fieldnames",[73,1237,1238],{"class":83}," =",[73,1240,1241],{"class":79}," fields)\n",[73,1243,1244],{"class":75,"line":498},[73,1245,587],{"emptyLinePlaceholder":586},[73,1247,1248],{"class":75,"line":515},[73,1249,1250],{"class":79},"    shows_w.writeheader()\n",[73,1252,1253,1256,1259,1261],{"class":75,"line":536},[73,1254,1255],{"class":83},"    for",[73,1257,1258],{"class":79}," item ",[73,1260,667],{"class":83},[73,1262,1263],{"class":79}," working_list:\n",[73,1265,1266],{"class":75,"line":561},[73,1267,1268],{"class":79},"        shows_w.writerow(item)\n",[12,1270,1271,1272,1275,1276,1278,1279,1282,1283,1285,1286,1289,1290,1293,1294,1297],{},"This previous code block creates a brand-new csv file by using the ",[59,1273,1274],{},"”w”"," parameter in ",[59,1277,912],{},". We manually name the fields in the order they appear in a separate list, then pass that list into the ",[59,1280,1281],{},"DictWriter"," parameter ",[59,1284,1235],{},". Finally, we use the ",[59,1287,1288],{},"writeheader()"," and a for loop with the ",[59,1291,1292],{},"writerow()"," methods to create a header row and to iterate over the ",[59,1295,1296],{},"working_list"," and turn each entry into a row in the .csv.",[12,1299,1300,1301,378],{},"These are only a few ways to work with .csv and .txt files; Python is very versatile and more information ",[22,1302,1305],{"href":1303,"rel":1304},"https://realpython.com/working-with-files-in-python/",[],"can be found here",[1307,1308,1309],"style",{},"html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html pre.shiki code .sD7c4, html code.shiki .sD7c4{--shiki-default:#D73A49}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html pre.shiki code .sqxcx, html code.shiki .sqxcx{--shiki-default:#E36209}",{"title":69,"searchDepth":90,"depth":90,"links":1311},[1312,1313],{"id":53,"depth":90,"text":54},{"id":770,"depth":90,"text":771,"children":1314},[1315,1316,1317],{"id":778,"depth":106,"text":779},{"id":905,"depth":106,"text":906},{"id":973,"depth":106,"text":974},"careers","2022-05-05","Our education evangelist Pj Metz continues his journey to learn how to code in Python.","md",null,false,"https://res.cloudinary.com/about-gitlab-com/image/upload/v1749664962/Blog/Hero%20Images/python.jpg",{},"/en-us/blog/learn-python-with-pj-part-4-dictionaries-and-files",{"title":5,"description":1320,"ogTitle":5,"ogDescription":1320,"noIndex":1323,"ogImage":1324,"ogUrl":1328,"ogSiteName":1329,"ogType":1330,"canonicalUrls":1328},"https://about.gitlab.com/blog/learn-python-with-pj-part-4-dictionaries-and-files","https://about.gitlab.com","article","learn-python-with-pj-part-4-dictionaries-and-files","en-us/blog/learn-python-with-pj-part-4-dictionaries-and-files",[1318,1334,1335],"tutorial","growth","BlogPost","okaM7jZ7npO28eVOi2Xfgd7Xol8T44L82_ooW84FGns",{"logo":1339,"freeTrial":1344,"sales":1349,"login":1354,"items":1359,"search":1695,"minimal":1727,"duo":1746,"switchNav":1755,"pricingDeployment":1766},{"config":1340},{"href":1341,"dataGaName":1342,"dataGaLocation":1343},"/","gitlab logo","header",{"text":1345,"config":1346},"Get free trial",{"href":1347,"dataGaName":1348,"dataGaLocation":1343},"https://gitlab.com/-/trial_registrations/new?glm_source=about.gitlab.com&glm_content=default-saas-trial/","free trial",{"text":1350,"config":1351},"Request a demo",{"href":1352,"dataGaName":1353,"dataGaLocation":1343},"/request-a-demo/","sales",{"text":1355,"config":1356},"Sign in",{"href":1357,"dataGaName":1358,"dataGaLocation":1343},"https://gitlab.com/users/sign_in/","sign in",[1360,1446,1534,1539,1619,1673],{"text":1361,"left":586,"config":1362,"menu":1364},"Platform",{"dataNavLevelOne":1363},"platform",{"type":1365,"link":1366,"columns":1370,"feature":1435},"lists",{"text":1367,"config":1368},"Explore the Platform",{"href":1369,"dataGaName":1363,"dataGaLocation":1343},"/platform/",[1371,1394,1417],{"title":1372,"items":1373},"DevOps",[1374,1379,1384,1389],{"text":1375,"config":1376},"CI/CD",{"href":1377,"dataGaLocation":1343,"dataGaName":1378},"/solutions/continuous-integration/","ci/cd",{"text":1380,"config":1381},"Source Code Management",{"href":1382,"dataGaLocation":1343,"dataGaName":1383},"/solutions/source-code-management/","source code management",{"text":1385,"config":1386},"Agile Delivery",{"href":1387,"dataGaLocation":1343,"dataGaName":1388},"/solutions/agile-delivery/","agile delivery",{"text":1390,"config":1391},"Artifact Management",{"href":1392,"dataGaLocation":1343,"dataGaName":1393},"/artifact-central/","artifact management",{"title":1395,"items":1396},"Security & Governance",[1397,1402,1407,1412],{"text":1398,"config":1399},"Application Security Testing",{"href":1400,"dataGaLocation":1343,"dataGaName":1401},"/solutions/application-security-testing/","application security testing",{"text":1403,"config":1404},"Governance & Compliance",{"href":1405,"dataGaLocation":1343,"dataGaName":1406},"/solutions/software-compliance/","governance and compliance",{"text":1408,"config":1409},"Secrets Management",{"href":1410,"dataGaLocation":1343,"dataGaName":1411},"/gitlab-secrets-manager/","secrets management",{"text":1413,"config":1414},"Supply Chain Security",{"href":1415,"dataGaLocation":1343,"dataGaName":1416},"/solutions/supply-chain/","supply chain security",{"title":1418,"items":1419},"Agentic AI & Context",[1420,1425,1430],{"text":1421,"config":1422},"Duo Agent Platform",{"href":1423,"dataGaLocation":1343,"dataGaName":1424},"/gitlab-duo-agent-platform/","duo agent platform",{"text":1426,"config":1427},"Orbit Context Graph",{"href":1428,"dataGaLocation":1343,"dataGaName":1429},"/gitlab-orbit/","orbit",{"text":1431,"config":1432},"Visibility & Measurement",{"href":1433,"dataGaLocation":1343,"dataGaName":1434},"/solutions/visibility-measurement/","visibility and measurement",{"config":1436,"title":1439,"text":1440,"link":1441},{"background":1437,"textColor":1438},"url('https://res.cloudinary.com/about-gitlab-com/image/upload/v1790185102/o7dn32anqcb6z8dgd3as.jpg')","#000","GitLab Orbit is generally available","Higher agent accuracy, lower token cost",{"text":1442,"config":1443},"Read the announcement",{"href":1444,"dataGaName":1445,"dataGaLocation":1343},"/blog/gitlab-orbit-ga/","orbit ga announcement",{"text":1447,"left":586,"config":1448,"menu":1450},"Solutions",{"dataNavLevelOne":1449},"solutions",{"type":1365,"link":1451,"columns":1455,"feature":1525},{"text":1452,"config":1453},"View all Solutions",{"href":1454,"dataGaName":1449,"dataGaLocation":1343},"/solutions/",[1456,1474,1492],{"title":1457,"items":1458},"Outcomes",[1459,1464,1469],{"text":1460,"config":1461},"DevOps Modernization",{"href":1462,"dataGaLocation":1343,"dataGaName":1463},"/assessments/devops-modernization-assessment/","devops modernization",{"text":1465,"config":1466},"Security Modernization",{"href":1467,"dataGaLocation":1343,"dataGaName":1468},"/assessments/security-modernization-assessment/","security modernization",{"text":1470,"config":1471},"AI Modernization",{"href":1472,"dataGaLocation":1343,"dataGaName":1473},"/assessments/ai-modernization-assessment/","ai modernization",{"title":1475,"items":1476},"By size",[1477,1482,1487],{"text":1478,"config":1479},"Enterprise",{"href":1480,"dataGaLocation":1343,"dataGaName":1481},"/enterprise/","enterprise",{"text":1483,"config":1484},"Small Business",{"href":1485,"dataGaLocation":1343,"dataGaName":1486},"/small-business/","small business",{"text":1488,"config":1489},"Startups",{"href":1490,"dataGaLocation":1343,"dataGaName":1491},"/solutions/startups/","startups",{"title":1493,"items":1494},"Industries",[1495,1500,1505,1510,1515,1520],{"text":1496,"config":1497},"Financial Services",{"href":1498,"dataGaLocation":1343,"dataGaName":1499},"/solutions/finance/","financial services",{"text":1501,"config":1502},"Public Sector",{"href":1503,"dataGaLocation":1343,"dataGaName":1504},"/solutions/public-sector/","public sector",{"text":1506,"config":1507},"Telecommunications",{"href":1508,"dataGaLocation":1343,"dataGaName":1509},"/solutions/telecommunications/","telecommunications",{"text":1511,"config":1512},"Automotive",{"href":1513,"dataGaLocation":1343,"dataGaName":1514},"/solutions/automotive/","automotive",{"text":1516,"config":1517},"Education",{"href":1518,"dataGaLocation":1343,"dataGaName":1519},"/solutions/education/","education",{"text":1521,"config":1522},"Aerospace",{"href":1523,"dataGaLocation":1343,"dataGaName":1524},"/solutions/aerospace/","aerospace",{"config":1526,"title":1527,"text":1528,"link":1529},{"background":1437,"textColor":1438},"GitLab Security Standard","Learn how to harden your software factory and let AI agents earn autonomy, without trading away security.",{"text":1530,"config":1531},"Explore the standard",{"href":1532,"dataGaName":1533,"dataGaLocation":1343},"/gitlab-security-standard/","gitlab security standard",{"text":1535,"config":1536},"Pricing",{"href":1537,"dataGaName":1538,"dataGaLocation":1343,"dataNavLevelOne":1538},"/pricing/","pricing",{"text":1540,"config":1541,"menu":1543},"Resources",{"dataNavLevelOne":1542},"resources",{"type":1365,"link":1544,"columns":1548,"feature":1610},{"text":1545,"config":1546},"View all resources",{"href":1547,"dataGaName":1542,"dataGaLocation":1343},"/resources/",[1549,1582],{"title":1550,"items":1551},"Discover",[1552,1557,1562,1567,1572,1577],{"text":1553,"config":1554},"Docs",{"href":1555,"dataGaName":1556,"dataGaLocation":1343},"https://docs.gitlab.com/","docs",{"text":1558,"config":1559},"University",{"href":1560,"dataGaName":1561,"dataGaLocation":1343},"https://university.gitlab.com/","university",{"text":1563,"config":1564},"Demo Series",{"href":1565,"dataGaName":1566,"dataGaLocation":1343},"/gitlab-technical-demo-series/","demo series",{"text":1568,"config":1569},"Demo Hub",{"href":1570,"dataGaName":1571,"dataGaLocation":1343},"/demo-hub/","demo hub",{"text":1573,"config":1574},"Services",{"href":1575,"dataGaName":1576,"dataGaLocation":1343},"/services/","services",{"text":1578,"config":1579},"Well Architected",{"href":1580,"dataGaName":1581,"dataGaLocation":1343},"/resources/well-architected/","well architected",{"title":1583,"items":1584},"Connect",[1585,1590,1595,1600,1605],{"text":1586,"config":1587},"Blog",{"href":1588,"dataGaName":1589,"dataGaLocation":1343},"/blog/","blog",{"text":1591,"config":1592},"Community",{"href":1593,"dataGaName":1594,"dataGaLocation":1343},"/community/","community",{"text":1596,"config":1597},"Customers",{"href":1598,"dataGaName":1599,"dataGaLocation":1343},"/customers/","customers",{"text":1601,"config":1602},"Partners",{"href":1603,"dataGaName":1604,"dataGaLocation":1343},"/partners/","partners",{"text":1606,"config":1607},"Events",{"href":1608,"dataGaName":1609,"dataGaLocation":1343},"/events/","events",{"config":1611,"title":1612,"text":1613,"link":1614},{"background":1437,"textColor":1438},"What’s new in GitLab","Stay updated with our latest features and improvements.",{"text":1615,"config":1616},"Read the latest",{"href":1617,"dataGaName":1618,"dataGaLocation":1343},"/whats-new/","whats new",{"text":1620,"config":1621,"menu":1623},"Company",{"dataNavLevelOne":1622},"company",{"type":1365,"columns":1624},[1625],{"items":1626},[1627,1632,1638,1643,1648,1653,1658,1663,1668],{"text":1628,"config":1629},"About",{"href":1630,"dataGaName":1631,"dataGaLocation":1343},"/company/","about",{"text":1633,"config":1634,"footerGa":1637},"Jobs",{"href":1635,"dataGaName":1636,"dataGaLocation":1343},"/jobs/","jobs",{"dataGaName":1636},{"text":1639,"config":1640},"Press",{"href":1641,"dataGaName":1642,"dataGaLocation":1343},"/press/","press",{"text":1644,"config":1645},"Handbook",{"href":1646,"dataGaName":1647,"dataGaLocation":1343},"https://handbook.gitlab.com/","handbook",{"text":1649,"config":1650},"Leadership",{"href":1651,"dataGaName":1652,"dataGaLocation":1343},"/company/team/e-group/","leadership",{"text":1654,"config":1655},"Investor relations",{"href":1656,"dataGaName":1657,"dataGaLocation":1343},"https://ir.gitlab.com/overview/default.aspx","investor relations",{"text":1659,"config":1660},"Trust Center",{"href":1661,"dataGaName":1662,"dataGaLocation":1343},"/security/","trust center",{"text":1664,"config":1665},"AI Transparency Center",{"href":1666,"dataGaName":1667,"dataGaLocation":1343},"/ai-transparency-center/","ai transparency center",{"text":1669,"config":1670},"Newsletter",{"href":1671,"dataGaName":1672,"dataGaLocation":1343},"/company/contact/#contact-forms","newsletter",{"text":1674,"config":1675,"menu":1676},"Contact us",{"dataNavLevelOne":1622},{"type":1365,"columns":1677},[1678],{"items":1679},[1680,1685,1690],{"text":1681,"config":1682},"Talk to sales",{"href":1683,"dataGaName":1684,"dataGaLocation":1343},"/sales/","talk to sales",{"text":1686,"config":1687},"Support portal",{"href":1688,"dataGaName":1689,"dataGaLocation":1343},"https://support.gitlab.com/hc/en-us","support portal",{"text":1691,"config":1692},"Customer portal",{"href":1693,"dataGaName":1694,"dataGaLocation":1343},"https://customers.gitlab.com/customers/sign_in/","customer portal",{"close":1696,"login":1697,"suggestions":1704},"Close",{"text":1698,"link":1699},"To search repositories and projects, login to",{"text":1700,"config":1701},"gitlab.com",{"href":1357,"dataGaName":1702,"dataGaLocation":1703},"search login","search",{"text":1705,"default":1706},"Suggestions",[1707,1710,1713,1715,1719,1723],{"text":1708,"config":1709},"GitLab Duo Agent Platform",{"href":1423,"dataGaName":1708,"dataGaLocation":1703},{"text":1711,"config":1712},"Code Suggestions (AI)",{"href":1423,"dataGaName":1711,"dataGaLocation":1703},{"text":1375,"config":1714},{"href":1377,"dataGaName":1375,"dataGaLocation":1703},{"text":1716,"config":1717},"GitLab on AWS",{"href":1718,"dataGaName":1716,"dataGaLocation":1703},"/partners/technology-partners/aws/",{"text":1720,"config":1721},"GitLab on Google Cloud",{"href":1722,"dataGaName":1720,"dataGaLocation":1703},"/partners/technology-partners/google-cloud-platform/",{"text":1724,"config":1725},"Why GitLab?",{"href":1726,"dataGaName":1724,"dataGaLocation":1703},"/why-gitlab/",{"freeTrial":1728,"mobileIcon":1733,"desktopIcon":1738,"secondaryButton":1741},{"text":1729,"config":1730},"Start free trial",{"href":1731,"dataGaName":1348,"dataGaLocation":1732},"https://gitlab.com/-/trials/new/","nav",{"altText":1734,"config":1735},"Gitlab Icon",{"src":1736,"dataGaName":1737,"dataGaLocation":1732},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1758203874/jypbw1jx72aexsoohd7x.svg","gitlab icon",{"altText":1734,"config":1739},{"src":1740,"dataGaName":1737,"dataGaLocation":1732},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1758203875/gs4c8p8opsgvflgkswz9.svg",{"text":1742,"config":1743},"Get Started",{"href":1744,"dataGaName":1745,"dataGaLocation":1732},"https://gitlab.com/-/trial_registrations/new?glm_source=about.gitlab.com/get-started/","get started",{"freeTrial":1747,"mobileIcon":1751,"desktopIcon":1753},{"text":1748,"config":1749},"Learn more about GitLab Duo",{"href":1423,"dataGaName":1750,"dataGaLocation":1732},"gitlab duo",{"altText":1734,"config":1752},{"src":1736,"dataGaName":1737,"dataGaLocation":1732},{"altText":1734,"config":1754},{"src":1740,"dataGaName":1737,"dataGaLocation":1732},{"button":1756,"mobileIcon":1761,"desktopIcon":1763},{"text":1757,"config":1758},"/switch",{"href":1759,"dataGaName":1760,"dataGaLocation":1732},"#contact","switch",{"altText":1734,"config":1762},{"src":1736,"dataGaName":1737,"dataGaLocation":1732},{"altText":1734,"config":1764},{"src":1765,"dataGaName":1737,"dataGaLocation":1732},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1773335277/ohhpiuoxoldryzrnhfrh.png",{"freeTrial":1767,"mobileIcon":1772,"desktopIcon":1774},{"text":1768,"config":1769},"Back to pricing",{"href":1537,"dataGaName":1770,"dataGaLocation":1732,"icon":1771},"back to pricing","GoBack",{"altText":1734,"config":1773},{"src":1736,"dataGaName":1737,"dataGaLocation":1732},{"altText":1734,"config":1775},{"src":1740,"dataGaName":1737,"dataGaLocation":1732},{"title":1777,"button":1778,"config":1782},"GitLab Orbit is generally available. Increase agent accuracy and lower token cost",{"text":1442,"config":1779},{"href":1444,"dataGaName":1780,"dataGaLocation":1781},"orbit-ga-banner","global-banner",{"layout":1783,"disabled":1323},"release",{"data":1785},{"text":1786,"config":1787,"items":1792,"minimal":2020},"Git is a trademark of Software Freedom Conservancy and our use of 'GitLab' is under license",{"twitter":1788,"facebook":1789,"youtube":1790,"linkedin":1791},"https://twitter.com/gitlab","https://www.facebook.com/gitlab","https://www.youtube.com/channel/UCnMGQ8QHMAnVIsI3xJrihhg","https://www.linkedin.com/company/gitlab-com",[1793,1841,1900,1947,1988],{"title":1535,"links":1794,"subMenu":1810},[1795,1800,1805],{"text":1796,"config":1797},"View plans",{"href":1537,"dataGaName":1798,"dataGaLocation":1799},"view plans","footer",{"text":1801,"config":1802},"Why Premium?",{"href":1803,"dataGaName":1804,"dataGaLocation":1799},"/pricing/premium/","why premium",{"text":1806,"config":1807},"Why Ultimate?",{"href":1808,"dataGaName":1809,"dataGaLocation":1799},"/pricing/ultimate/","why ultimate",[1811],{"title":1812,"links":1813},"Contact Us",[1814,1817,1819,1821,1826,1831,1836],{"text":1815,"config":1816},"Contact sales",{"href":1683,"dataGaName":1353,"dataGaLocation":1799},{"text":1686,"config":1818},{"href":1688,"dataGaName":1689,"dataGaLocation":1799},{"text":1691,"config":1820},{"href":1693,"dataGaName":1694,"dataGaLocation":1799},{"text":1822,"config":1823},"Status",{"href":1824,"dataGaName":1825,"dataGaLocation":1799},"https://status.gitlab.com/","status",{"text":1827,"config":1828},"Terms of use",{"href":1829,"dataGaName":1830,"dataGaLocation":1799},"/terms/","terms of use",{"text":1832,"config":1833},"Privacy statement",{"href":1834,"dataGaName":1835,"dataGaLocation":1799},"/privacy/","privacy statement",{"text":1837,"config":1838},"Cookie preferences",{"dataGaName":1839,"dataGaLocation":1799,"id":1840,"isOneTrustButton":586},"cookie preferences","ot-sdk-btn",{"title":1361,"links":1842,"subMenu":1858},[1843,1846,1848,1850,1852,1854],{"text":1844,"config":1845},"Explore the platform",{"href":1369,"dataGaName":1363,"dataGaLocation":1799},{"text":1421,"config":1847},{"href":1423,"dataGaName":1424,"dataGaLocation":1799},{"text":1375,"config":1849},{"href":1377,"dataGaName":1378,"dataGaLocation":1799},{"text":1426,"config":1851},{"href":1428,"dataGaName":1429,"dataGaLocation":1799},{"text":1408,"config":1853},{"href":1410,"dataGaName":1411,"dataGaLocation":1799},{"text":1855,"config":1856},"Why GitLab",{"href":1726,"dataGaName":1857,"dataGaLocation":1799},"why gitlab",[1859],{"title":1860,"links":1861},"Topics",[1862,1866,1871,1875,1880,1885,1890,1895],{"text":1375,"config":1863},{"href":1864,"dataGaName":1865,"dataGaLocation":1799},"/topics/ci-cd/","cicd",{"text":1867,"config":1868},"GitOps",{"href":1869,"dataGaName":1870,"dataGaLocation":1799},"/topics/gitops/","gitops",{"text":1372,"config":1872},{"href":1873,"dataGaName":1874,"dataGaLocation":1799},"/topics/devops/","devops",{"text":1876,"config":1877},"Version Control",{"href":1878,"dataGaName":1879,"dataGaLocation":1799},"/topics/version-control/","version control",{"text":1881,"config":1882},"DevSecOps",{"href":1883,"dataGaName":1884,"dataGaLocation":1799},"/topics/devsecops/","devsecops",{"text":1886,"config":1887},"Cloud Native",{"href":1888,"dataGaName":1889,"dataGaLocation":1799},"/topics/cloud-native/","cloud native",{"text":1891,"config":1892},"AI for Coding",{"href":1893,"dataGaName":1894,"dataGaLocation":1799},"/topics/devops/ai-for-coding/","ai for coding",{"text":1896,"config":1897},"Agentic AI",{"href":1898,"dataGaName":1899,"dataGaLocation":1799},"/topics/agentic-ai/","agentic ai",{"title":1447,"links":1901},[1902,1905,1908,1911,1914,1917,1919,1921,1923,1925,1927,1930,1932,1935,1939,1943],{"text":1903,"config":1904},"DevOps modernization",{"href":1462,"dataGaName":1463,"dataGaLocation":1799},{"text":1906,"config":1907},"Security modernization",{"href":1467,"dataGaName":1468,"dataGaLocation":1799},{"text":1909,"config":1910},"AI modernization",{"href":1472,"dataGaName":1473,"dataGaLocation":1799},{"text":1912,"config":1913},"Financial services",{"href":1498,"dataGaName":1499,"dataGaLocation":1799},{"text":1915,"config":1916},"Public sector",{"href":1503,"dataGaName":1504,"dataGaLocation":1799},{"text":1506,"config":1918},{"href":1508,"dataGaName":1509,"dataGaLocation":1799},{"text":1511,"config":1920},{"href":1513,"dataGaName":1514,"dataGaLocation":1799},{"text":1516,"config":1922},{"href":1518,"dataGaName":1519,"dataGaLocation":1799},{"text":1521,"config":1924},{"href":1523,"dataGaName":1524,"dataGaLocation":1799},{"text":1478,"config":1926},{"href":1480,"dataGaName":1481,"dataGaLocation":1799},{"text":1928,"config":1929},"Small business",{"href":1485,"dataGaName":1486,"dataGaLocation":1799},{"text":1488,"config":1931},{"href":1490,"dataGaName":1491,"dataGaLocation":1799},{"text":1867,"config":1933},{"href":1934,"dataGaName":1870,"dataGaLocation":1799},"/solutions/gitops/",{"text":1936,"config":1937},"Software composition analysis",{"href":1415,"dataGaName":1938,"dataGaLocation":1799},"software composition analysis",{"text":1940,"config":1941},"Value stream management",{"href":1433,"dataGaName":1942,"dataGaLocation":1799},"value stream management",{"text":1944,"config":1945},"All solutions",{"href":1454,"dataGaName":1946,"dataGaLocation":1799},"all solutions",{"title":1540,"links":1948},[1949,1954,1959,1961,1963,1965,1967,1969,1971,1973,1975,1977,1979,1981,1984],{"text":1950,"config":1951},"Install",{"href":1952,"dataGaName":1953,"dataGaLocation":1799},"/install/","install",{"text":1955,"config":1956},"Quick start guides",{"href":1957,"dataGaName":1958,"dataGaLocation":1799},"/get-started/","quick setup checklists",{"text":1553,"config":1960},{"href":1555,"dataGaName":1556,"dataGaLocation":1799},{"text":1558,"config":1962},{"href":1560,"dataGaName":1561,"dataGaLocation":1799},{"text":1563,"config":1964},{"href":1565,"dataGaName":1566,"dataGaLocation":1799},{"text":1568,"config":1966},{"href":1570,"dataGaName":1571,"dataGaLocation":1799},{"text":1573,"config":1968},{"href":1575,"dataGaName":1576,"dataGaLocation":1799},{"text":1586,"config":1970},{"href":1588,"dataGaName":1589,"dataGaLocation":1799},{"text":1591,"config":1972},{"href":1593,"dataGaName":1594,"dataGaLocation":1799},{"text":1596,"config":1974},{"href":1598,"dataGaName":1599,"dataGaLocation":1799},{"text":1601,"config":1976},{"href":1603,"dataGaName":1604,"dataGaLocation":1799},{"text":1606,"config":1978},{"href":1608,"dataGaName":1609,"dataGaLocation":1799},{"text":1669,"config":1980},{"href":1671,"dataGaName":1672,"dataGaLocation":1799},{"text":1982,"config":1983},"What's new",{"href":1617,"dataGaName":1618,"dataGaLocation":1799},{"text":1985,"config":1986},"All resources",{"href":1547,"dataGaName":1987,"dataGaLocation":1799},"all resources",{"title":1620,"links":1989},[1990,1992,1994,1996,1998,2000,2002,2004,2006,2010,2015],{"text":1628,"config":1991},{"href":1630,"dataGaName":1622,"dataGaLocation":1799},{"text":1633,"config":1993},{"href":1635,"dataGaName":1636,"dataGaLocation":1799},{"text":1639,"config":1995},{"href":1641,"dataGaName":1642,"dataGaLocation":1799},{"text":1644,"config":1997},{"href":1646,"dataGaName":1647,"dataGaLocation":1799},{"text":1649,"config":1999},{"href":1651,"dataGaName":1652,"dataGaLocation":1799},{"text":1654,"config":2001},{"href":1656,"dataGaName":1657,"dataGaLocation":1799},{"text":1659,"config":2003},{"href":1661,"dataGaName":1662,"dataGaLocation":1799},{"text":1664,"config":2005},{"href":1666,"dataGaName":1667,"dataGaLocation":1799},{"text":2007,"config":2008},"Sustainability",{"href":2009,"dataGaName":2007,"dataGaLocation":1799},"/sustainability/",{"text":2011,"config":2012},"Diversity, inclusion and belonging (DIB)",{"href":2013,"dataGaName":2014,"dataGaLocation":1799},"/diversity-inclusion-belonging/","Diversity, inclusion and belonging",{"text":2016,"config":2017},"Modern Slavery Transparency Statement",{"href":2018,"dataGaName":2019,"dataGaLocation":1799},"https://handbook.gitlab.com/handbook/legal/modern-slavery-act-transparency-statement/","modern slavery transparency statement",{"items":2021},[2022,2025,2028],{"text":2023,"config":2024},"Terms",{"href":1829,"dataGaName":1830,"dataGaLocation":1799},{"text":2026,"config":2027},"Cookies",{"dataGaName":1839,"dataGaLocation":1799,"id":1840,"isOneTrustButton":586},{"text":2029,"config":2030},"Privacy",{"href":1834,"dataGaName":1835,"dataGaLocation":1799},[2032],{"id":2033,"title":2034,"body":1322,"config":2035,"content":2037,"description":1322,"extension":2041,"meta":2042,"navigation":586,"path":2043,"seo":2044,"stem":2045,"__hash__":2046},"blogAuthors/en-us/blog/authors/pj-metz.yml","Pj Metz",{"template":2036},"BlogAuthor",{"name":7,"config":2038},{"headshot":2039,"ctfId":2040},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1749659488/Blog/Author%20Headshots/gitlab-logo-extra-whitespace.png","PjMetz","yml",{},"/en-us/blog/authors/pj-metz",{},"en-us/blog/authors/pj-metz","SgW84Gu-lPq0zFzhy1aT23bZjx9kWViDG_WXzCPn04E",[2048,2056,2062],{"title":2049,"description":2050,"heroImage":2051,"category":1318,"date":2052,"authors":2053,"slug":2055,"externalUrl":1322},"Shadow programs give employees a peek into leadership roles","Shadow programs are a great resource if you’re looking to explore new roles, expand your skill set, or learn how decisions are made.","https://res.cloudinary.com/about-gitlab-com/image/upload/v1749683055/Blog/Hero%20Images/ideaabstract.jpg","2023-07-17",[2054],"Fatima Sarah Khalid","benefits-of-corporate-shadow-programs",{"title":2057,"description":2058,"heroImage":1324,"category":1318,"date":2059,"authors":2060,"slug":2061,"externalUrl":1322},"Learn Python with Pj! Part 5 - Build a hashtag tracker with the Twitter API","Our Education Evangelist Pj Metz wraps up his five-part series with this penultimate tutorial.","2022-06-01",[7],"learn-python-with-pj-part-5-building-something-with-the-twitter-api",{"title":2063,"description":2064,"heroImage":2065,"category":1318,"date":2066,"authors":2067,"slug":2069,"externalUrl":1322},"5 ways collaboration boosts productivity and your career","Collaboration is a powerful tool and DevOps pros that learn how to master it will expand their growth opportunities.","https://res.cloudinary.com/about-gitlab-com/image/upload/v1749668473/Blog/Hero%20Images/john-schnobrich-FlPc9_VocJ4-unsplash.jpg","2022-05-02",[2068],"Sharon Gaudin","5-ways-collaboration-boosts-productivity-and-your-career",{"header":2071,"text":2072,"button":2076,"disclaimer":2079},"Start your free\n\n30-day GitLab trial\n",[2073,2074,2075],"GitLab Duo Agent Platform access","Try our most advanced features","Automate complex tasks with AI",{"text":1345,"config":2077},{"href":2078,"dataGaName":1348,"dataGaLocation":1589},"https://gitlab.com/-/trials/new?glm_content=default-saas-trial&glm_source=about.gitlab.com/blog/","No credit card required.",{"header":2081,"blurb":2082,"button":2083,"secondaryButton":2088},"Start building faster today","See what your team can do with the intelligent orchestration platform for DevSecOps.\n",{"text":2084,"config":2085},"Get your free trial",{"href":2086,"dataGaName":1348,"dataGaLocation":2087},"https://gitlab.com/-/trial_registrations/new?glm_content=default-saas-trial&glm_source=about.gitlab.com/","feature",{"text":1815,"config":2089},{"href":1683,"dataGaName":1353,"dataGaLocation":2087},1794911782121]